OnKeyUp event

Started by Dovys, October 24, 2023, 12:40:13 PM

Previous topic - Next topic

Dovys

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.

Fred Tomke

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Dovys

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.

Fred Tomke

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Dovys

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.

Fred Tomke

That means, you have a solution now?
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Dovys

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

Fred Tomke

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]