product: Visual LANSA (Web page)
version: V15 (EPC150040)
Our customer wants to move focus using Enter key instead of Tab key.
Is there any useful property? (like FLDX=Y for forms)
In the meantime, the following coding will give the desired behavior.
However, if there is a better coding, I'd like to know that as well.
Code: Select all
Begin_Com Role(*EXTENDS #PRIM_WEB)
Define Field(#LASPOS) Type(*SIGNED) Length(2) Decimals(0)
Define Field(#FOCPOS) Type(*SIGNED) Length(2) Decimals(0)
Define_Com Class(#PRIM_PANL) Name(#Panel1) Displayposition(1) Left(56) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(24) Height(248) Width(529)
Define_Com Class(#DEPTMENT.Visual) Name(#DEPTMENT) Displayposition(1) Left(56) Parent(#Panel1) Tabposition(1) Top(16) Height(20) Width(224)
Define_Com Class(#DEPTDESC.Visual) Name(#DEPTDESC) Displayposition(2) Left(56) Parent(#Panel1) Tabposition(2) Top(48) Height(20) Width(418)
Define_Com Class(#STD_DATEX.Visual) Name(#STD_DATEX) Displayposition(3) Left(56) Parent(#Panel1) Tabposition(3) Top(80) Height(20) Width(310)
Define_Com Class(#SECTION.Visual) Name(#SECTION) Displayposition(4) Left(56) Parent(#Panel1) Tabposition(4) Top(112) Height(20) Width(200)
Define_Com Class(#PRIM_PHBN) Name(#Button1) Caption('Button1') Displayposition(5) Left(75) Parent(#Panel1) Tabposition(5) Top(162)
Define_Com Class(#PRIM_LIST) Name(#List1) Displayposition(6) Left(192) Parent(#Panel1) Tabposition(6) Top(144)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnSECADDR11) Columnwidth(189) Displayposition(1) Parent(#List1) Source(#SECADDR1)
Define_Com Class(#PRIM_STPG) Name(#ShortcutKey1) Parent(#Panel1) Shortcut(Enter)
Evtroutine Handling(#Com_owner.CreateInstance)
* #LASPOS: get last TabPosition
For Each(#ELEMENT) In(#Panel1.ComponentControls)
If Cond(#LASPOS < #ELEMENT.TabPosition)
#LASPOS := #ELEMENT.TabPosition
Endif
Endfor
Endroutine
Evtroutine Handling(#ShortcutKey1.Pressed)
* #FOCPOS: TabPosition of the component which has the focus currently
For Each(#FOCUSELEMENT) In(#Panel1.ComponentControls)
If Cond(#FOCUSELEMENT.Focus)
#FOCPOS := #FOCUSELEMENT.TabPosition
Leave
Endif
Endfor
* set the focus for the next component
#FOCPOS += 1
For Each(#ELEMENT) In(#Panel1.ComponentControls)
* set the focus for the component of TabPosition(1)
If Cond(#FOCPOS *GT #LASPOS)
If Cond(#ELEMENT.TabPosition *EQ 1)
#ELEMENT.SetFocus
Leave
Endif
Else
If Cond(#ELEMENT.TabPosition *EQ #FOCPOS)
#ELEMENT.SetFocus
Leave
Endif
Endif
Endfor
Endroutine
End_Com
Best regards, Yukiko Ikeo