User avatar
Gazoo
Topic Author
Posts: 36
Joined: 14 Sep 2022, 10:00
Contact:

[Solved] Passing keyboard input to NoesisGUI from other Framework

20 Sep 2022, 09:23

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
Last edited by Gazoo on 23 Sep 2022, 03:13, edited 1 time in total.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Passing keyboard input to NoesisGUI from other Framework

20 Sep 2022, 10:28

Hi,

Key events have to be passed to View using the following methods:
    /// 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;
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.
 
User avatar
Gazoo
Topic Author
Posts: 36
Joined: 14 Sep 2022, 10:00
Contact:

Re: Passing keyboard input to NoesisGUI from other Framework

20 Sep 2022, 10:48

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
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Passing keyboard input to NoesisGUI from other Framework

20 Sep 2022, 11:44

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?
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Passing keyboard input to NoesisGUI from other Framework

20 Sep 2022, 16:33

Also, the order in which these events are sent is important. Please, check our Win32Display implementation.
/// 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;
 
User avatar
Gazoo
Topic Author
Posts: 36
Joined: 14 Sep 2022, 10:00
Contact:

Re: Passing keyboard input to NoesisGUI from other Framework

22 Sep 2022, 01:15

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
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Passing keyboard input to NoesisGUI from other Framework

22 Sep 2022, 02:16

it would be up to me to determine a double-click occurring and dispatch right call to NoesisGui, yes?
Yes, that's correct.
 
User avatar
Gazoo
Topic Author
Posts: 36
Joined: 14 Sep 2022, 10:00
Contact:

Re: Passing keyboard input to NoesisGUI from other Framework

23 Sep 2022, 03:12

Gotcha - thank you very much for all the answers.

Who is online

Users browsing this forum: No registered users and 101 guests