1. I sill can't figure this focus thing out
- Posted by doncole2009 Apr 24, 2009
- 800 views
I create 3 columns of EditTexts.
col1={EditText10,EditText11,EditText12,EditText13...etc}
col2={EditText20,EditText21,EditText22,EditText23...etc}
col3={EditText30,EditText31,EditText32,EditText33...etc}
What I want to do is,
Go to EditText20. If there is text inside then focus it.
If not move on down to EditText21 and keep going until an EditText is found with text in it. Then focus it.
Now that text inside can be changed or not changed.
I either case return is hit.
Then I want to go down col1 until an EditText with Text in it is found.
Then focus that one. And so on. If the bottom EditText of col1 is hit then I want to go
back to the top EditText(EditText20) of col1. And keep doing that over and over again.
Now here's the hard part.
At no time during this process do I want any EditTexts in col1 or col3 to focus or blink.
Can anybody help?
Don Cole A Bug is an un-documentedfeature. A Feature is a documented Bug.
2. Re: I sill can't figure this focus thing out
- Posted by ghaberek (admin) Apr 24, 2009
- 789 views
When you process the w32HKeyPress event, are you calling returnValue( -1 ) to cancel any further event processing?
-Greg
3. Re: I sill can't figure this focus thing out
- Posted by DerekParnell (admin) Apr 24, 2009
- 782 views
You may be experiencing a bug in win32lib. Currently, when a RETURN key has been pressed in an edittext control, the focus is automatically moved to the next control in the tabbing order. This happens even if the KeyPress handler has asked the system to ignore the RETURN key (by calling returnValue(-1))
I've just uploaded a fix for this to the library's SVN, but if you want to patch your local copy of the library do this ...
- Locate the routine called 'fDoChar' in win32lib.ew
- Find the line
if wParam = VK_RETURN and shifts = 0 and ctrl_Type[id] = EditText then
- Change it to ...
if wParam = VK_RETURN and shifts = 0 and ctrl_Type[id] = EditText and lUserReturn[1] != -1
Hope this helps.
Here is the test program that I used...
----- include win32lib.ew constant win = create(Window, "Don's Issue", 0, 0, 0, 400, 800, 0) sequence Cols procedure onKeyPress(integer self, integer msg, sequence parms) integer c integer p integer newc integer newp if parms[1] != VK_ENTER then return end if c = 1 while c <= 3 do p = find(self, Cols[c]) if p != 0 then exit end if c += 1 end while if c > 3 then return end if if p = length(Cols[c]) then if c = 3 then c = 1 else c += 1 end if p = 1 else p += 1 end if newp = p newc = c while 1 do if length(getText(Cols[c][p])) = 0 then p += 1 if p > length(Cols[c]) then c += 1 if c > length(Cols) then c = 1 end if p = 1 end if else exit end if if newp = p and newc = c then exit end if end while setFocus(Cols[c][p]) returnValue(-1) end procedure procedure MakeEdits() integer x integer y integer w integer h integer vg integer hg integer col sequence winrect winrect = getClientSize(win) vg = 3 hg = 15 x = 5 y = 10 w = 55 h = 23 col = 1 Cols = {{},{},{}} ? winrect while y < winrect[4] - h - vg do x = 5 for i =1 to 3 do Cols[i] &= create(EditText, "", win, x, y, w, h, 0) setHandler(Cols[i][$], w32HKeyPress, routine_id("onKeyPress")) x += w + hg end for y += h + vg end while end procedure MakeEdits() WinMain(win, 0)
4. Re: I sill can't figure this focus thing out
- Posted by doncole2009 Apr 24, 2009
- 779 views
Thank you Derek,
In trying your fix it seems I was using win32lib.ew v0.60.6.
I upgraded to win32lib v0.70.3.
This in itself this seems to have fixed the problem.
However in my code I am using doEvents(0) instead of returnValue(-1) which is incorrect.
I have to change my code to returnValue(-1). This will take a while.
I DO believe you hit the nail on the head because the reason I am using doEvents(0) is because returnValue(-1) didn't work.
Thanks again Derek.
Don Cole A Bug is an un-documentedfeature. A Feature is a documented Bug.