1. focus problem

This is my EditText layout in a window.

ET1 ET2 ET3

ET4 ET5 ET6

ET7 ET8 ET9

What I want to do:

1. open window with ET1 in focus. (I know how to do that).

2. onKeyDown of ET1 I want focus to go to ET5 (not ET2).

3. onKeyDown of ET5 I want focus to go to ET9.

4. onKeyDown of ET9 I want focus to go back to ET1 and so on.

How can I do that?

I'm using the following code but it doesn't work.

 
procedure ET_onKeyDown (integer self, integer event, sequence params)--params is ( atom scanCode, atom shift ) 
   if params[1]	= 13 then 
      if self=ET1 then 
         setFocus(ET5) 
      elsif self=ET5 then 
         setFocus(ET9) 
      elsif self=ET9 then 
         setFocus(ET1) 
      end if 
end procedure 
setHandler({ET1,ET5,ET9} w32HKeyDown, routine_id("ETonKeyDown")) 
 
procedure Window1_onActivate (integer self, integer event, sequence params)--params is () 
   setFocus(ET1) 
end procedure 
setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) 

Don Cole

new topic     » topic index » view message » categorize

2. Re: focus problem

Are you using the latest version of Win32Lib?

https://sourceforge.net/projects/win32libex/files/v_0_70_20/

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: focus problem

dcole said...

What I want to do:

1. open window with ET1 in focus. (I know how to do that).

2. onKeyDown of ET1 I want focus to go to ET5 (not ET2).

3. onKeyDown of ET5 I want focus to go to ET9.

4. onKeyDown of ET9 I want focus to go back to ET1 and so on.

How can I do that?

According to the documentation on EditText controls, you need this ...


Note that when the user presses the Return Key, the focus will move to the next control in the focus order. To prevent this from happening, you need to set a w32HKeyPress handler that sets the return value to -1 when a VK_RETURN key without shifts is received.

      procedure IgnoreReturn(integer self, integer event, sequence parms) 
          if parms[1] = VK_RETURN and parms[2] = 0 then 
              returnValue(-1) 
          end if 
      end procedure 
      setHandler(myEditField, w32HKeyPress, routine_id("IgnoreReturn") 

new topic     » goto parent     » topic index » view message » categorize

4. Re: focus problem

DerekParnell said...

According to the documentation on EditText controls, you need this ...


Note that when the user presses the Return Key, the focus will move to the next control in the focus order. To prevent this from happening, you need to set a w32HKeyPress handler that sets the return value to -1 when a VK_RETURN key without shifts is received.

      procedure IgnoreReturn(integer self, integer event, sequence parms) 
          if parms[1] = VK_RETURN and parms[2] = 0 then 
              returnValue(-1) 
          end if 
      end procedure 
      setHandler(myEditField, w32HKeyPress, routine_id("IgnoreReturn") 

Thank you Derek,

This does deflect the focus from the next EditText in the focus order.

But how do I focus the one I want?

Don Cole

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu