OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Dovys on October 24, 2023, 12:40:13 PM

Title: OnKeyUp event
Post by: Dovys on October 24, 2023, 12:40:13 PM
Hi,
I am trying to use OnKeyUp event on TextBox, it works if I use letter buttons, but if I try to use buttons above letter buttons like button "@" in text box I see symbol "@", but function KeyUp gives me number "2" in variable Character.
I try to get non English letters from this buttons after I set Keyboard layout to my language and here are some letters on buttons "@", "$" and so on.
Like button "@" have letter "Č" and button "$" have letter "Ė". But I only get number 2 or 4.
Title: Re: OnKeyUp event
Post by: Fred Tomke on October 24, 2023, 01:57:32 PM
Hi, that depends on the keys you need to input @ character. For the German keyboard layout I need to press AltGr to get @ sign. So the numer 2 and 4 are the key codes for the additional key.
I hope it was understandable.
With regards, Fred
Title: Re: OnKeyUp event
Post by: Dovys on October 24, 2023, 10:35:56 PM
I don't understand if we talk about same thing so I will try to explain in more details.

I use Visual Studio Code as my IDE. I have run lisp with OpenDCL in debug mode from VSC.
After I open GUI made with OpenDCL in AutoCAD and enter symbol into text box I see @ but in VSC variable "Character" is 2

(defun c:Savartos/Main/TBGNew#OnKeyUp (Character RepeatCount Flags /)

Because of this if I want to check if symbol @ was entered I don't know how, because in lisp I only see number 2. I have attached image.
Title: Re: OnKeyUp event
Post by: Fred Tomke on October 25, 2023, 01:31:12 AM
Hi, I'm not sure if you know that many events will be fired for a single @-char?
I attached a small example for demonstration. I hope I'm on the right path, sorry if not.
With regards, Fred
Title: Re: OnKeyUp event
Post by: Dovys on October 25, 2023, 06:14:49 AM
Hi,
yes, I know here are more events on key press.
I have tested you code (attached image). In window you can see 6 events.
1) Shift key Down.
2) @ key Down.
3) Shift key Up.
4) @ key Up.
5) 2 key Down.
6) 2 key Up.

And in Input you can see @2
shift key Char is unknown and ASCII is 16, but in case of @ and 2 both are Char 2 and ASCII 50. This means it is not possible to get @ symbol (and all other symbols in this button row on keyboard) in lisp.
Input text box have symbol @ but lisp have events of two key presses.

Writing this messages I got how can I get it. All I need from key up event is only even itself, but I don't need Character variable, I just need to read content of text box.
In my code only one letter can be entered in text box and this letter needs to be in hard coded list and not be in list of already entered letters.

Thanks for help.
Title: Re: OnKeyUp event
Post by: Fred Tomke on October 25, 2023, 06:40:32 AM
That means, you have a solution now?
Fred
Title: Re: OnKeyUp event
Post by: Dovys on October 25, 2023, 07:30:59 AM
Yes.
(defun c:Savartos/Main/TBGNew#OnKeyUp (Character RepeatCount Flags / letter)
  (setq letter (dcl-Control-GetText Savartos/Main/TBGNew))
)

I just ignore "Character RepeatCount Flags" and take text from text box with dcl-Control-GetText
Title: Re: OnKeyUp event
Post by: Fred Tomke on October 25, 2023, 08:40:23 AM
Great! I only use KeyDown in some ListViews and grids to recognize, when Delete was pressed. Changes in textboxes I always check with EditChanged or Update event.
Regards, Fred