1. Grid Control: Check box state reverse reported?
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Feb 13, 2003
- 652 views
Phil, When I now check for the state of a newly clicked checkbox, I get the opposite of what it is. I could of course just reverse them for use, but I'm worried it could be some kind of time anomaly which could act differently on differing systems. Modification below at the end of your last code shows this. Dan -- code generated by Win32Lib IDE v0.14.2 include Win32lib.ew without warning ---------------------------------------------------------------------------- ---- -- Window Window1 constant Window1 = createEx( Window, "Grid Control with CheckBoxes", 0, Default, Default, 600, 300, 0, 0 ) constant PushButton2 = createEx( PushButton, "Select File", Window1, 484, 20, 88, 28, 0, 0 ) constant PushButton3 = createEx( PushButton, "Process Data", Window1, 484, 72, 88, 28, 0, 0 ) --------------------------------------------------------- ---------------------------------------------------------------------------- ---- include eugrid.ew atom void integer aGrid, colFileName, colCB1, colCB2, colFileDir -- Create grid, create parms=(parent, x, y, width, height, show_window) aGrid = EGW_CreateGrid( Window1, 10, 15, 450, 200, True ) -- no row header void = EGW_SetGridProperty( aGrid, EGW_ROW_HEADER_WIDTH, 0) --***Phil: Make grid look a bit more like a list view void = EGW_SetGridProperty( aGrid, EGW_NULL_GRID_COLOR, BrightWhite) void = EGW_SetGridProperty( aGrid, EGW_LINE_COLOR, BrightWhite) void = EGW_SetGridProperty( aGrid, EGW_CELL_BORDER, False) -- Filename column -- ***Phil: Make this a protected edit field to get highlighting --colFileName = EGW_AddColumn( aGrid, "FileName", 200, EGW_LAST,EGW_STATIC, 1 ) colFileName = EGW_AddColumn( aGrid, "FileName", 100, EGW_LAST, EGW_EDIT, 1 ) --void = EGW_SetColumnProperty(aGrid, colFileName, EGW_COL_ALIGN,EGW_CENTER) void = EGW_SetColumnProperty(aGrid, colFileName, EGW_COL_EDITABLE, False) --void = EGW_SetColumnProperty( aGrid, colFileName, EGW_COL_WIDTH, 75 ) -- checkbox columns: colCB1 = EGW_AddColumn(aGrid, "Action1", 60, EGW_LAST, EGW_CHECKBOX, 2 ) void = EGW_SetColumnProperty(aGrid, colCB1, EGW_COL_ALIGN, EGW_CENTER) colCB2 = EGW_AddColumn(aGrid, "Action2", 60, EGW_LAST, EGW_CHECKBOX, 3 ) void = EGW_SetColumnProperty(aGrid, colCB2, EGW_COL_ALIGN, EGW_CENTER) -- file directory column: colFileDir = EGW_AddColumn( aGrid, "FileDirectory", 226, EGW_LAST, EGW_STATIC, 4 ) --void = EGW_SetColumnProperty(aGrid, colFileDir, EGW_COL_ALIGN,EGW_CENTER) ---------------------------------------------------------------------------- ---- procedure PushButton2_onClick (integer self, integer event, sequence params)--params is () seq fName, dirName, fullPathName, temp seq newRow int row, posBS -- posBS is position of back-slash in file name temp = {} -- get a file name fName = getOpenFileName( Window1, current_dir() & "\\", "" ) -- entered a file name? if length( fName ) = 0 then return end if -- separate filename from dirName: if find('\\',fName) then -- found back-slash -- work from end, remove chars after last back-slash: for n = length(fName) to 1 by -1do if not equal('\\',fName[n]) then temp = prepend(temp,fName[n]) else posBS = n exit end if end for fullPathName = fName dirName = fName[1..posBS -1] fName = temp else dirName = "" end if newRow = {fName,1,1,dirName } -- example relating to adding new row: --global constant EmptyGridRow = {"", 2, "", "", 0, True} -- Add new row to grid: row = EGW_AddDataRow(aGrid, newRow, EGW_LAST) --***Phil: Not necessary unless you are doing database manipulation *** --void = EGW_SetDataRowFlag(aGrid, row, EGW_ROW_NEW, True) -- Go to it? --***Phil: You can't use EGW_LAST here - use row number from EGW_AddDataRow instead -- void = EGW_ScrollToCell(aGrid, EGW_LAST, colFileName) --repaintWindow(Window1) --***Phil Start -- Repaint window to make sure new row is displayed repaintWindow(aGrid) -- Scroll to first column of new row void = EGW_ScrollToCell( aGrid, row, colFileName ) --***Phil End end procedure setHandler( PushButton2, w32HClick, routine_id("PushButton2_onClick")) ---------------------------------------------------------------------------- ---- procedure PushButton3_onClick (integer self, integer event, sequence params)--params is () object result atom numOfRows numOfRows = EGW_GetRowCount ( aGrid ) for n = 1 to numOfRows do result = EGW_GetDataCellValue ( aGrid, n, 2 ) puts(1, sprint(result)) result = EGW_GetDataCellValue ( aGrid, n, 3 ) puts(1, sprint(result)) puts(1, "\n") end for end procedure setHandler( PushButton3, w32HClick, routine_id("PushButton3_onClick")) --*------------------------------------------------------* -- onGridEvent: Process messages for grid control --*------------------------------------------------------* procedure onGridEvent (atom self, atom event, sequence parms) atom msg, wParam, lParam sequence cell object cbState msg = parms[1] wParam = parms[2] lParam = parms[3] -- User has clicked on a cell if msg = EGW_CLICK then cell = EGW_GetCurrentCell( aGrid ) -- get state of clicked checkbox: cbState = EGW_GetDataCellValue ( aGrid, cell[1], cell[2] ) if cell[2] = 2 or cell[2] = 3 then -- is a checkbox column setText( Window1, "Clicked on row number: " & sprint(cell[1]) & ",column id: " & sprint(cell[2]) & " ,state: " & sprint(cbState) ) if cbState then -- box is newly checked else -- box is newly un-checked end if end if end if end procedure setHandler( aGrid, w32HEvent, routine_id("onGridEvent")) WinMain( Window1,Normal )
2. Re: Grid Control: Check box state reverse reported?
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Feb 13, 2003
- 645 views
Phil, Oh, I *saw* that happening when I clicked, held, & then released the mouse button, but didn't grasp the (now obvious) significance! (I'd have probably understood if I had been watching the title bar also & seen the state change report, but I was just looking at the checkbox itself.) But now I can confidently just change a received "1" to a "0" & "0" to "1", & then remove that when you post the change. Thanks. Dan ----- Original Message ----- From: "Phil Russell" <pg_russell at lineone.net> To: "EUforum" <EUforum at topica.com> Sent: Thursday, February 13, 2003 6:34 AM Subject: RE: Grid Control: Check box state reverse reported? > > Dan, > > It is not a timing problem. What is happening is that EGW_CLICK is sent > when you press the mouse button down, but the value in the checkbox only > changes when the mouse button comes up (this is the default behaviour > for checkboxes I believe). I had been meaning to change this in the > next release to add two messages EGW_LEFTBUTTONDOWN and EGW_LEFTBUTTONUP > to cope with this. As it is a minor change I will try and do this in > the next day or so and post the change to Rob. Can't think of a > workaround in the meantime I am afraid... > > Regards, > > Phil > > > Dan Moyer wrote: > > Phil, > > > > When I now check for the state of a newly clicked checkbox, I get the > > opposite of what it is. I could of course just reverse them for use, > > but > > I'm worried it could be some kind of time anomaly which could act > > differently on differing systems. Modification below at the end of your > > last code shows this. > > <snipped code from reply>
3. Re: Grid Control: Check box state reverse reported?
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Feb 13, 2003
- 634 views
Oops, you're right, there's no good work around, can't use an onClick the grid (mouse down) & then test inside the event for state of checkbox when it doesn't change until mouse up. Will wait until you post fix. Dan ----- Original Message ----- From: "Dan Moyer" <DANIELMOYER at prodigy.net> To: "EUforum" <EUforum at topica.com> Subject: Re: Grid Control: Check box state reverse reported? > > Phil, > > Oh, I *saw* that happening when I clicked, held, & then released the mouse > button, but didn't grasp the (now obvious) significance! (I'd have probably > understood if I had been watching the title bar also & seen the state change > report, but I was just looking at the checkbox itself.) But now I can > confidently just change a received "1" to a "0" & "0" to "1", & then remove > that when you post the change. > > Thanks. > > Dan > ----- Original Message ----- > From: "Phil Russell" <pg_russell at lineone.net> > To: "EUforum" <EUforum at topica.com> > Sent: Thursday, February 13, 2003 6:34 AM > Subject: RE: Grid Control: Check box state reverse reported? > > > > Dan, > > > > It is not a timing problem. What is happening is that EGW_CLICK is sent > > when you press the mouse button down, but the value in the checkbox only > > changes when the mouse button comes up (this is the default behaviour > > for checkboxes I believe). I had been meaning to change this in the > > next release to add two messages EGW_LEFTBUTTONDOWN and EGW_LEFTBUTTONUP > > to cope with this. As it is a minor change I will try and do this in > > the next day or so and post the change to Rob. Can't think of a > > workaround in the meantime I am afraid... > > > > Regards, > > > > Phil > > > > > > Dan Moyer wrote: > > > Phil, > > > > > > When I now check for the state of a newly clicked checkbox, I get the > > > opposite of what it is. I could of course just reverse them for use, > > > but > > > I'm worried it could be some kind of time anomaly which could act > > > differently on differing systems. Modification below at the end of your > > > last code shows this. > > > > <snipped code from reply> > > > > TOPICA - Start your own email discussion group. FREE! >
4. Re: Grid Control: Check box state reverse reported?
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Feb 14, 2003
- 645 views
Phil, Great! Waiting for Rob to put it up on the Euphoria site. Dan ----- Original Message ----- From: "Phil Russell" <pg_russell at lineone.net> To: "EUforum" <EUforum at topica.com> Subject: RE: Grid Control: Check box state reverse reported? > > Dan, > > Just sent the fixed version to Rob (see my previous post). Amended > example code showing (hopefully) the correct checkbox state is attached > below. > > Let me know if it is OK. > > Ta, > > Phil > > Dan Moyer wrote: > > Oops, you're right, there's no good work around, can't use an onClick > > the > > grid (mouse down) & then test inside the event for state of checkbox > > when it > > doesn't change until mouse up. Will wait until you post fix. > > > > Dan > > > > Code follows: > > -- code generated by Win32Lib IDE v0.14.2 > > include Win32lib.ew > without warning > > -------------------------------------------------------------------------- -- > > > ---- > -- Window Window1 > constant Window1 = createEx( Window, "Grid Control with CheckBoxes", 0, > Default, Default, 600, 300, 0, 0 ) > constant PushButton2 = createEx( PushButton, "Select File", Window1, > 484, > 20, 88, 28, 0, 0 ) > constant PushButton3 = createEx( PushButton, "Process Data", Window1, > 484, > 72, 88, 28, 0, 0 ) > --------------------------------------------------------- > -------------------------------------------------------------------------- -- > > > ---- > include eugrid.ew > atom void > > integer aGrid, colFileName, colCB1, colCB2, colFileDir > > -- Create grid, create parms=(parent, x, y, width, height, show_window) > aGrid = EGW_CreateGrid( Window1, 10, 15, 450, 200, True ) > > -- no row header > void = EGW_SetGridProperty( aGrid, EGW_ROW_HEADER_WIDTH, 0) > > --***Phil: Make grid look a bit more like a list view > void = EGW_SetGridProperty( aGrid, EGW_NULL_GRID_COLOR, BrightWhite) > void = EGW_SetGridProperty( aGrid, EGW_LINE_COLOR, BrightWhite) > void = EGW_SetGridProperty( aGrid, EGW_CELL_BORDER, False) > > -- Filename column > -- ***Phil: Make this a protected edit field to get highlighting > --colFileName = EGW_AddColumn( aGrid, "FileName", 200, > EGW_LAST,EGW_STATIC,1 ) > colFileName = EGW_AddColumn( aGrid, "FileName", 100, EGW_LAST, > EGW_EDIT,1 ) > --void = EGW_SetColumnProperty(aGrid, colFileName, > EGW_COL_ALIGN,EGW_CENTER) > void = EGW_SetColumnProperty(aGrid, colFileName, EGW_COL_EDITABLE, > False) > --void = EGW_SetColumnProperty( aGrid, colFileName, EGW_COL_WIDTH, 75 ) > > -- checkbox columns: > colCB1 = EGW_AddColumn(aGrid, "Action1", 60, EGW_LAST, EGW_CHECKBOX, 2 ) > void = EGW_SetColumnProperty(aGrid, colCB1, EGW_COL_ALIGN, EGW_CENTER) > colCB2 = EGW_AddColumn(aGrid, "Action2", 60, EGW_LAST, EGW_CHECKBOX, 3 ) > void = EGW_SetColumnProperty(aGrid, colCB2, EGW_COL_ALIGN, EGW_CENTER) > > -- file directory column: > colFileDir = EGW_AddColumn( aGrid, "FileDirectory", 226, EGW_LAST, > EGW_STATIC, 4 ) > --void = EGW_SetColumnProperty(aGrid, colFileDir, > EGW_COL_ALIGN,EGW_CENTER) > -------------------------------------------------------------------------- -- > > > ---- > procedure PushButton2_onClick (integer self, integer event, sequence > params)--params is () > seq fName, dirName, fullPathName, temp > seq newRow > int row, posBS -- posBS is position of back-slash in file name > > temp = {} > > -- get a file name > fName = getOpenFileName( Window1, current_dir() & "\\", "" ) > -- entered a file name? > if length( fName ) = 0 then > return > end if > > -- separate filename from dirName: > if find('\\',fName) then -- found back-slash > -- work from end, remove chars after last back-slash: > for n = length(fName) to 1 by -1do > if not equal('\\',fName[n]) then > temp = prepend(temp,fName[n]) > else > posBS = n > exit > end if > end for > > fullPathName = fName > dirName = fName[1..posBS -1] > fName = temp > else > dirName = "" > end if > > newRow = {fName,1,1,dirName } > > -- example relating to adding new row: > --global constant EmptyGridRow = {"", 2, "", "", 0, True} > > -- Add new row to grid: > row = EGW_AddDataRow(aGrid, newRow, EGW_LAST) > > --***Phil: Not necessary unless you are doing database manipulation *** > --void = EGW_SetDataRowFlag(aGrid, row, EGW_ROW_NEW, True) > > -- Go to it? > --***Phil: You can't use EGW_LAST here - use row number from > EGW_AddDataRowinstead > -- void = EGW_ScrollToCell(aGrid, EGW_LAST, colFileName) > --repaintWindow(Window1) > > --***Phil Start > -- Repaint window to make sure new row is displayed > repaintWindow(aGrid) > -- Scroll to first column of new row > void = EGW_ScrollToCell( aGrid, row, colFileName ) > --***Phil End > end procedure > setHandler( PushButton2, w32HClick, routine_id("PushButton2_onClick")) > -------------------------------------------------------------------------- -- > > > ---- > procedure PushButton3_onClick (integer self, integer event, sequence > params)--params is () > object result > atom numOfRows > > numOfRows = EGW_GetRowCount ( aGrid ) > > for n = 1 to numOfRows do > result = EGW_GetDataCellValue ( aGrid, n, 2 ) > puts(1, sprint(result)) > result = EGW_GetDataCellValue ( aGrid, n, 3 ) > puts(1, sprint(result)) > puts(1, "\n") > end for > > end procedure > setHandler( PushButton3, w32HClick, routine_id("PushButton3_onClick")) > --*------------------------------------------------------* > -- onGridEvent: Process messages for grid control > --*------------------------------------------------------* > procedure onGridEvent (atom self, atom event, sequence parms) > atom msg, wParam, lParam > sequence cell > object cbState > > msg = parms[1] > wParam = parms[2] > lParam = parms[3] > > -- User has clicked on a cell > if msg = EGW_LEFTBUTTONUP then > cell = EGW_GetCurrentCell( aGrid ) > > -- get state of clicked checkbox: > cbState = EGW_GetDataCellValue ( aGrid, cell[1], cell[2] ) > if cell[1]>0 and (cell[2] = colCB1 or cell[2] = colCB2) then -- is a > checkbox column > > setText( Window1, "Clicked on row number: " & sprint(cell[1]) > & ", column id: " & sprint(cell[2]) > & " , state: " & sprint(cbState) ) > end if > end if > > end procedure > setHandler( aGrid, w32HEvent, routine_id("onGridEvent")) > > WinMain( Window1,Normal ) > > > > TOPICA - Start your own email discussion group. FREE! >
5. Re: Grid Control: Check box state reverse reported?
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Feb 14, 2003
- 624 views
Phil, The new message & the demo using it works fine! Could be helpful to include the demo with your control's distribution. Dan ----- Original Message ----- From: "Phil Russell" <pg_russell at lineone.net> To: "EUforum" <EUforum at topica.com> Subject: RE: Grid Control: Check box state reverse reported? > > Dan, > > Just sent the fixed version to Rob (see my previous post). Amended > example code showing (hopefully) the correct checkbox state is attached > below. > > Let me know if it is OK. > > Ta, > > Phil > > Dan Moyer wrote: > > Oops, you're right, there's no good work around, can't use an onClick > > the > > grid (mouse down) & then test inside the event for state of checkbox > > when it > > doesn't change until mouse up. Will wait until you post fix. > > > > Dan > > > > Code follows: > > -- code generated by Win32Lib IDE v0.14.2 > > include Win32lib.ew > without warning > > -------------------------------------------------------------------------- -- > > > ---- > -- Window Window1 > constant Window1 = createEx( Window, "Grid Control with CheckBoxes", 0, > Default, Default, 600, 300, 0, 0 ) > constant PushButton2 = createEx( PushButton, "Select File", Window1, > 484, > 20, 88, 28, 0, 0 ) > constant PushButton3 = createEx( PushButton, "Process Data", Window1, > 484, > 72, 88, 28, 0, 0 ) > --------------------------------------------------------- > -------------------------------------------------------------------------- -- > > > ---- > include eugrid.ew > atom void > > integer aGrid, colFileName, colCB1, colCB2, colFileDir > > -- Create grid, create parms=(parent, x, y, width, height, show_window) > aGrid = EGW_CreateGrid( Window1, 10, 15, 450, 200, True ) > > -- no row header > void = EGW_SetGridProperty( aGrid, EGW_ROW_HEADER_WIDTH, 0) > > --***Phil: Make grid look a bit more like a list view > void = EGW_SetGridProperty( aGrid, EGW_NULL_GRID_COLOR, BrightWhite) > void = EGW_SetGridProperty( aGrid, EGW_LINE_COLOR, BrightWhite) > void = EGW_SetGridProperty( aGrid, EGW_CELL_BORDER, False) > > -- Filename column > -- ***Phil: Make this a protected edit field to get highlighting > --colFileName = EGW_AddColumn( aGrid, "FileName", 200, > EGW_LAST,EGW_STATIC,1 ) > colFileName = EGW_AddColumn( aGrid, "FileName", 100, EGW_LAST, > EGW_EDIT,1 ) > --void = EGW_SetColumnProperty(aGrid, colFileName, > EGW_COL_ALIGN,EGW_CENTER) > void = EGW_SetColumnProperty(aGrid, colFileName, EGW_COL_EDITABLE, > False) > --void = EGW_SetColumnProperty( aGrid, colFileName, EGW_COL_WIDTH, 75 ) > > -- checkbox columns: > colCB1 = EGW_AddColumn(aGrid, "Action1", 60, EGW_LAST, EGW_CHECKBOX, 2 ) > void = EGW_SetColumnProperty(aGrid, colCB1, EGW_COL_ALIGN, EGW_CENTER) > colCB2 = EGW_AddColumn(aGrid, "Action2", 60, EGW_LAST, EGW_CHECKBOX, 3 ) > void = EGW_SetColumnProperty(aGrid, colCB2, EGW_COL_ALIGN, EGW_CENTER) > > -- file directory column: > colFileDir = EGW_AddColumn( aGrid, "FileDirectory", 226, EGW_LAST, > EGW_STATIC, 4 ) > --void = EGW_SetColumnProperty(aGrid, colFileDir, > EGW_COL_ALIGN,EGW_CENTER) > -------------------------------------------------------------------------- -- > > > ---- > procedure PushButton2_onClick (integer self, integer event, sequence > params)--params is () > seq fName, dirName, fullPathName, temp > seq newRow > int row, posBS -- posBS is position of back-slash in file name > > temp = {} > > -- get a file name > fName = getOpenFileName( Window1, current_dir() & "\\", "" ) > -- entered a file name? > if length( fName ) = 0 then > return > end if > > -- separate filename from dirName: > if find('\\',fName) then -- found back-slash > -- work from end, remove chars after last back-slash: > for n = length(fName) to 1 by -1do > if not equal('\\',fName[n]) then > temp = prepend(temp,fName[n]) > else > posBS = n > exit > end if > end for > > fullPathName = fName > dirName = fName[1..posBS -1] > fName = temp > else > dirName = "" > end if > > newRow = {fName,1,1,dirName } > > -- example relating to adding new row: > --global constant EmptyGridRow = {"", 2, "", "", 0, True} > > -- Add new row to grid: > row = EGW_AddDataRow(aGrid, newRow, EGW_LAST) > > --***Phil: Not necessary unless you are doing database manipulation *** > --void = EGW_SetDataRowFlag(aGrid, row, EGW_ROW_NEW, True) > > -- Go to it? > --***Phil: You can't use EGW_LAST here - use row number from > EGW_AddDataRowinstead > -- void = EGW_ScrollToCell(aGrid, EGW_LAST, colFileName) > --repaintWindow(Window1) > > --***Phil Start > -- Repaint window to make sure new row is displayed > repaintWindow(aGrid) > -- Scroll to first column of new row > void = EGW_ScrollToCell( aGrid, row, colFileName ) > --***Phil End > end procedure > setHandler( PushButton2, w32HClick, routine_id("PushButton2_onClick")) > -------------------------------------------------------------------------- -- > > > ---- > procedure PushButton3_onClick (integer self, integer event, sequence > params)--params is () > object result > atom numOfRows > > numOfRows = EGW_GetRowCount ( aGrid ) > > for n = 1 to numOfRows do > result = EGW_GetDataCellValue ( aGrid, n, 2 ) > puts(1, sprint(result)) > result = EGW_GetDataCellValue ( aGrid, n, 3 ) > puts(1, sprint(result)) > puts(1, "\n") > end for > > end procedure > setHandler( PushButton3, w32HClick, routine_id("PushButton3_onClick")) > --*------------------------------------------------------* > -- onGridEvent: Process messages for grid control > --*------------------------------------------------------* > procedure onGridEvent (atom self, atom event, sequence parms) > atom msg, wParam, lParam > sequence cell > object cbState > > msg = parms[1] > wParam = parms[2] > lParam = parms[3] > > -- User has clicked on a cell > if msg = EGW_LEFTBUTTONUP then > cell = EGW_GetCurrentCell( aGrid ) > > -- get state of clicked checkbox: > cbState = EGW_GetDataCellValue ( aGrid, cell[1], cell[2] ) > if cell[1]>0 and (cell[2] = colCB1 or cell[2] = colCB2) then -- is a > checkbox column > > setText( Window1, "Clicked on row number: " & sprint(cell[1]) > & ", column id: " & sprint(cell[2]) > & " , state: " & sprint(cbState) ) > end if > end if > > end procedure > setHandler( aGrid, w32HEvent, routine_id("onGridEvent")) > > WinMain( Window1,Normal ) > > > > TOPICA - Start your own email discussion group. FREE! >