Options

Check whether the ENTER key was pressed

MACL2MACL2 Member Posts: 10
How can I find out in C/AL whether the user has pressed the ENTER key? Can I use a .NET assembly (Dotnet Variable) for this purpose?

Comments

  • Options
    vaprogvaprog Member Posts: 1,124
    edited 2015-11-11
    Where do you need it? What do you need it for?
    There might be NAV ways of doing, what you need to do.
  • Options
    MACL2MACL2 Member Posts: 10
    It is for a terminal Dialog (time Registration) that Needs to be built in the Windows client. In the old NAV version (Classic Client) that the customer used before, there was a form with big text boxes and Buttons. Now with the pages the standard layout/design possibilities are limited so in order to have the same big text boxes and Buttons my colleague used the uniwpf-client-addin (see https://uniwpfaddin.codeplex.com/). Now when you type something into the TextBox, an Event is fired and in the control-addin-Trigger you can respond to this Event using C/AL code. In the text box the employee no. can be typed in. Our customer will also use Scanners to scan the employee no. and then the scanner will also send ENTER in order initiate the process. The Problem is, that the event for this text box is fired every time a single character was entered. Now I want the process to be initiated only when the ENTER key was sent. Only then the employee no. is complete and I can use it. That's why I am looking for a way to find out whether the ENTER key was pressed. The C/AL code I want to write for this purpose is in the Control-addin-Trigger. Thank you for any suggestions.
  • Options
    kinekine Member Posts: 12,562
    1) I am happy that someone is using the addin... ;-)
    2) Try to use another event on the textbox. I do not know which you are using now, you can try to use KeyUp/KeyDown event. If this event is not supported in the project by default (the KeyEventHandler type is unknown for the addin), the code of the addin could be extended by this event type. Passing the args back to NAV will give you scan code of pressed key.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    MACL2MACL2 Member Posts: 10
    Hello Kine,

    Thank you very much for the input. I have implemented the code (see lines marked in yellow in the attached Word document). But somehow the code is not triggered. Im I missing something?
    Best regards,
    MACL2
  • Options
    kinekine Member Posts: 12,562
    Have you used <SetEvent Object="objname" Name="EventName"/> to subscribe the event?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    MACL2MACL2 Member Posts: 10
    That was the missing link. Thank you. It worked.
  • Options
    mdPartnerNLmdPartnerNL Member Posts: 802
    in which version are you using this?
Sign In or Register to comment.