Page 1 of 1

Change focus on TAB or Enter

Posted: Mon Nov 07, 2011 11:37 am
by jdsoft
Hello,
I have a window with multiple DCGET's.
Every get has a VALID clause.

I can navigate from a DCGET to another DCGET in 4 ways:
1. Tab-key
2. Enter-key
3. Shift-Tab key
4. Mouseclick in other DCGET

How can i set focus to a special field if i navigate with the Tab-key or the Enter-Key?
The working of Shift-Tab and Mouseclick should not change.

My current code looks like:

Code: Select all

@  nLine,nTab2 DCGET oTekening:breedte PICTURE "9999.99" ;
               WHEN {||lEdit} ;
               VALID {||Tekening_Herberekenen_Plaat(oTekening,GetList),SetAppFocus(oBewerking),TRUE}
But this changes focus to the oBewerking at all navigation.
I tryed to use

Code: Select all

iif(LastAppEvent()=xbeK_TAB,SetAppFocus(oBewerking),nil)
in the Valid clause, but it always returns the same value 1048629.

Suggestions are welcome.

Regards,
Jack Duijf

Re: Change focus on TAB or Enter

Posted: Tue Nov 08, 2011 12:03 am
by Wolfgang Ciriack
Hi Jack,
you can try

Code: Select all

iif(dc_readguilastkey(Getlist)=xbeK_ENTER, setAppFocus(oBewerking),NIL), .T. }

Re: Change focus on TAB or Enter

Posted: Tue Nov 08, 2011 4:54 am
by jdsoft
Hello Wolfgang,

Thank you for the suggestion. All works as expected now.
This resulted in the folowing code:

Code: Select all

LOCAL bKeyFocus      := {|o|Set_KeyFocus(GetList,o)}
DCGET .... VALID {||Tekening_Herberekenen_Plaat(oTekening,GetList),Eval(bKeyFocus,@oBewerking),TRUE}

Procedure Set_KeyFocus(GetList,o)
LOCAL nLastkey       := Dc_ReadGuiLastkey(GetList)
do case
   case nLastkey = xbeK_TAB
      SetAppFocus(o)
      Dc_ReadGuiLastkey(GetList,0)
   case nLastkey = xbeK_ENTER
      SetAppFocus(o)
      Dc_ReadGuiLastkey(GetList,0)
endcase
Return
Regards,
Jack Duijf