Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Textbox keyboard key detection

  1. #1
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658

    Textbox keyboard key detection

    Hello,

    I've searched for this but couldn't find anything.
    Is it possible to detect what key from a keyboard has been pressed?

    For example, how do I determine if 'f' or '5' or 'enter' is pressed?

    I'm thinking of a couple of scenarios:
    1. Accept only numeric values
    2. Pressing enter calls another function.

    Any help and examples would be greatly appreciated.

    Cory

  2. #2
    Hi Cory,

    Have you looked at inkey()

    I haven't had a chance to test it out in lianaj, but I suspect it should work.

    Herb

  3. #3
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Hi Herb and Cory,

    I believe Herb meant lastkey(), which is mentioned in the Wiki but does not yet have its own entry.

    But that said, Cory, to accept only numeric values you would use the either the inputmask or the special format codes for the input mask. @9 allows only numeric entries. Here's a link to the topic where Barry lets us in on the secret codes <s>: http://www.lianja.com/community/show...on-text-fields

    hth,

    Hank

    PS: to call another function when the user exits the control, put that function in the Validation delegate for the control. Return .t. if you want to allow the user to go on from there; .f. if you want the user to get the assigned error message (from the database or from the control's error message attribute; and 0 if you don't want an error message, but want the user to remain in the control (you might have shown them a custom message and want to bypass the assigned error message. At least the latter should work: I haven't tested in Lianja.

    Quote Originally Posted by hmischel@diligentsystems.com View Post
    Hi Cory,

    Have you looked at inkey()

    I haven't had a chance to test it out in lianaj, but I suspect it should work.

    Herb
    Last edited by HankFay; 2013-11-21 at 20:08.

  4. #4
    Hi Hank, Cory,

    I did mean inkey()

    It is similar to lastkey.

    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx


    proc page1_section1_field3_interactivechange()
    wait window inkey()
    endproc

    Now since this is an interactive event, it looks to only capture values that are displayed.

    Herb

  5. #5
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hello Gentlemen,

    Thank you very much for your replies.

    Hank, @9 seems to work, however I had to reload the app for the change to take effect.

    Herb, inkey() seems to cover almost everything.
    In order to get the enter key accepted, I placed it in the change event instead of the interactive event.
    This works except for one big issue.

    Inkey registers the enter key from the numeric keypad, although it doesn't seem to recognize the main enter key.
    To my knowledge, but enter keys should register as key code 13.

    The main keyboard enter key registers as 16777220 which I find weird.

    Cory
    Last edited by CGibson; 2013-11-22 at 09:46.

  6. #6
    Hi Cory,

    If it's consistent, then go with. Have the app capture for either value.

    Herb

  7. #7
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hello,

    I have enabled the textbox dialog button.
    Now when I press either enter key, the code from the dialog button is activated instead of the code in the change event.

    Since the focus is in the textbox and is not on the button, how do I get the enter key to be recognized as a key pressed and active the proper code?

    Cory

  8. #8
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,842
    Hi Cory,

    I'm not seeing that behaviour - can you submit a ticket with the code to reproduce it attached, please?

    Thanks,

    Yvonne

  9. #9
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi Yvonne,

    Ticket has been submitted.
    TECH-0000002258

    Cory.

  10. #10
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,842
    Thanks!

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us