Enter key to move focus

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Yukiko Ikeo
Posts: 26
Joined: Fri Jun 09, 2017 11:58 pm

Enter key to move focus

Post by Yukiko Ikeo »

Hi all,

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

Thanks in advance.
Best regards, Yukiko Ikeo
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Enter key to move focus

Post by Dino »

Hi Yukiko

I think your solution is very efficient for what has been requested. I have seen equivalent workaround in javascript like here:
https://stackoverflow.com/questions/100 ... javascript

and basically is doing the same.
Yukiko Ikeo
Posts: 26
Joined: Fri Jun 09, 2017 11:58 pm

Re: Enter key to move focus

Post by Yukiko Ikeo »

Hi Dino,

Sorry for the late reply.
Thank you for your response :)

Best regards, Yukiko Ikeo
Post Reply