Accueil → WINDEV 23 → How to enable ENTER key in Table to trigger a proc
How to enable ENTER key in Table to trigger a proc
Débuté par Adrianmak, 03 juil. 2018 12:24 - 6 réponses
Posté le 03 juillet 2018 - 12:24
Dear All,

I'm trying to use ENTER key when user is browsing in a TABLE to launch a proc related to the current row in that table.

I have created a button off window with shortcut as Enter key which works already.
However, problem is there are many other controls in the same window.
Now even the current control is not the table (eg. An Edit date control) and user press enter it will launch it incorrectly.

Please your advise to handle this properly.
I cant find a windev function to test the current active control ie. The table.

Many thanks in advance

Posté le 03 juillet 2018 - 13:01
There is a function ControlCurrent

Posté le 04 juillet 2018 - 09:43
Thank Bart for the pointer.

I do use the function now to detect source of action and it solved the previous problem.
However, a new issue arises. Now when the focus is on another button eg. Close and user press Enter, WD will launch the procedure instead of closing or executing the close code as before.
Seems like the hidden button shortcut (enter) takes precedence over all other controls.

Any advise how to avoid this is highly appreciated.

Thanks again.
Posté le 04 juillet 2018 - 09:55
Hi Adrian,

you could add the "key pressed" process (wm_char) to your table control and execute your code there. Select the table and press F2 then you can see all processes

your code

note that you also have to include this line somewhere. i.e. your project init-section or some other 'global' place
EXTERN "KeyConst.WL"
Posté le 04 juillet 2018 - 12:21
Many thanks Arie.

I changed to detection method per your suggestion as it is more natural. And it now works perfectly.

Posté le 04 juillet 2018 - 14:33
Hi All,

I just noticed a problem when using key pressed detection on table control.
Normally i want to launch the procedure only when user press Enter while navigating at table row. But now when user type in at the table header for filtering purpose, then press Enter afterward, it will incorrectly launch the proc too.

Kindly advise how to differentiate/recognize user enter-ing from table header so that I can add code to exclude such.

Thanks again

Posté le 04 juillet 2018 - 19:33
A bit more code but TableInfoXY() may be your friend