Page 1 of 1
Listbox Problem
Posted: Tue Aug 28, 2007 11:31 am
by xProgrammer
I am using a listbox to enable one of four possible locations to be selected. The current location is read from the database and the listbox selection set to match with code like the following:
Code: Select all
@3, 45 LISTBOX lbLocations VAR sThisLoc OF dlgPatFile ;
ITEMS ::aLocName SIZE 180, 110
FOR liTry = 1 TO ::nLocs
IF ::aLocKey[liTry] = ::sFLKey
lbLocations:nAt = liTry
ENDIF
NEXT
This works but the problem is that if you tab into the listbox the selection changes to the first entry in the listbox. This only happens the first time you tab into it, if you tab through it a second time whatever has been selected remains unchanged. I need a fix or a workaround to prevent or circumvent this behaviour.
Thanks
xProgrammer
Posted: Fri Aug 31, 2007 7:05 am
by Antonio Linares
Doug,
We have been trying to fix that behavior without luck yet
Thanks for effort and advice
Posted: Fri Aug 31, 2007 7:23 am
by xProgrammer
Antonio
Thanks for your effort and advice. I will start investigating workarounds. But a fix would be highly desirable.
One possibility is to use a get for the current value (read only) plus a listbox and a button labelled "change to" - a bit complex if there are multiple listboxes on the one screen.
I'll try a one column grid although that may behave in the same way.
Thanks
Doug (xProgrammer)
Tried a 1 column grid
Posted: Fri Aug 31, 2007 8:11 am
by xProgrammer
Antonio
I tried a 1 column BROWSE. Setting oBrw:nAt worked in the sense that it selected the correct row but it also made that row the top row of the browse - which is not what I want. I haven't yet figured out how to use oBrw:oVScroll to scroll back to the top (hopefully without moving the currently highlighted row).
Thanks
Doug (xProgrammer)
A suggestion
Posted: Fri Aug 31, 2007 11:42 am
by xProgrammer
Antonio
A possible work around might be if the LISTBOX class supported code blocks that were evaluated for the SETFOCUS and LOSTFOCUS events. The we could keep track of the last value and reset it. Not perfect - the screen might flash a bit, but possibly workable.
I also note that it only happens the first time you tab into the listbox, and if you click the mouse on the listbox before tabbing into it, the behaviour doesn't occur.
This suggested that programmatically setting focus to the listbox might solve the problem. I tried that (prior to dialog activation) but it didn't work. Maybe if we could do it in an ON INIT method (and so after dialog activation) that might work.
Maybe one of these approaches will work.
Regards
Doug (xProgrammer)