[Solved] Passing keyboard input to NoesisGUI from other Framework
Hello peoples,
The applications framework I use (LibCinder) has its own character enum for incoming keys. I'm guessing there's not much else to do than write a conversion table if I want to properly pass things through to NoesisGui?
I've seen the Char() function, but I'm assuming this doesn't easily pass through non-character keys?
Thanks in advance,
Gazoo
The applications framework I use (LibCinder) has its own character enum for incoming keys. I'm guessing there's not much else to do than write a conversion table if I want to properly pass things through to NoesisGui?
I've seen the Char() function, but I'm assuming this doesn't easily pass through non-character keys?
Thanks in advance,
Gazoo
Last edited by Gazoo on 23 Sep 2022, 03:13, edited 1 time in total.
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Passing keyboard input to NoesisGUI from other Framework
Hi,
Key events have to be passed to View using the following methods:
KeyDown/Up are to notify of a key press/release event. This is where you will translate your LibCinder enum to the Noesis Key enum.
Char method is to send the translated unicode character corresponding to a key combination (A for the 'a' character, Shift+A for the 'A' character, ´+A for the 'á' character, etc.), in Win32 API it corresponds to the WM_CHAR message. This is what is used to feed the TextBox with the actual text.
Hope this helps.
Key events have to be passed to View using the following methods:
Code: Select all
/// Notifies that a key was initially pressed or repeatedly pressed
/// Returns true if event was handled
virtual bool KeyDown(Key key) = 0;
/// Notifies that a key was released.
/// Returns true if event was handled
virtual bool KeyUp(Key key) = 0;
/// Notifies that a key was translated to the corresponding unicode character.
/// If a key is repeatedly pressed, its corresponding 'Char' event is sent again.
/// 'Char' messages are expected to be sent between the corresponding 'Down' and 'Up' events:
/// - KeyDown
/// - Char
/// - KeyUp
/// Returns true if event was handled
virtual bool Char(uint32_t ch) = 0;
Char method is to send the translated unicode character corresponding to a key combination (A for the 'a' character, Shift+A for the 'A' character, ´+A for the 'á' character, etc.), in Win32 API it corresponds to the WM_CHAR message. This is what is used to feed the TextBox with the actual text.
Hope this helps.
Re: Passing keyboard input to NoesisGUI from other Framework
Much appreciate the prompt response sfernandez!
From your response I glean that the only way forward is to convert between the two character Enum's, which is fair enough.
One question remains for me - Is it a requirement to also call the Char() function to make sure text gets passed through to a TextBox? In other words, it is not sufficient to merely pass on all keystrokes via KeyDown() and KeyUp()?
Cheers,
Gazoo
From your response I glean that the only way forward is to convert between the two character Enum's, which is fair enough.
One question remains for me - Is it a requirement to also call the Char() function to make sure text gets passed through to a TextBox? In other words, it is not sufficient to merely pass on all keystrokes via KeyDown() and KeyUp()?
Cheers,
Gazoo
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Passing keyboard input to NoesisGUI from other Framework
In order for TextBox to work properly you have to send the Char events with the translated characters. I guess there should be some way to get the character from the key event in LibCinder, have you checked that?
Re: Passing keyboard input to NoesisGUI from other Framework
Also, the order in which these events are sent is important. Please, check our Win32Display implementation.
Code: Select all
/// Notifies that a key was translated to the corresponding unicode character.
/// If a key is repeatedly pressed, its corresponding 'Char' event is sent again.
/// 'Char' messages are expected to be sent between the corresponding 'Down' and 'Up' events:
/// - KeyDown
/// - Char
/// - KeyUp
/// Returns true if event was handled
virtual bool Char(uint32_t ch) = 0;
Re: Passing keyboard input to NoesisGUI from other Framework
sfernandez - Yes, I believe getting the decoded char should be possible.
jsantos - Thanks, noted!
One additional question re. input integration:
I also noticed that NoesisGui has an explicit "void MouseDoubleClick()" call, as per this page: https://www.noesisengine.com/docs/Gui.C ... html#mouse
I don't think LibCinder registers 'double clicks' meaning, it would be up to me to determine a double-click occurring and dispatch right call to NoesisGui, yes?
Cheers,
Gazoo
jsantos - Thanks, noted!
One additional question re. input integration:
I also noticed that NoesisGui has an explicit "void MouseDoubleClick()" call, as per this page: https://www.noesisengine.com/docs/Gui.C ... html#mouse
I don't think LibCinder registers 'double clicks' meaning, it would be up to me to determine a double-click occurring and dispatch right call to NoesisGui, yes?
Cheers,
Gazoo
Re: Passing keyboard input to NoesisGUI from other Framework
Yes, that's correct.it would be up to me to determine a double-click occurring and dispatch right call to NoesisGui, yes?
Re: Passing keyboard input to NoesisGUI from other Framework
Gotcha - thank you very much for all the answers.
Who is online
Users browsing this forum: Google [Bot] and 79 guests