679 views
in System Integration by

Hi,

I have  a device that has buttons.

How Can I know the time the user pressed on the button and what button was pressed?

For example: if the user pressed on the down arrow, I would move the focus to another filed...

Thanks,

Michal.

2 Answers

+1 vote
by
 
Best answer

Hello Michal,

think on the buttons as if they were keyboard keys. With the Key Press Handler you can react to keyboard events. 

The remaining question is, how to feed the events when the user presses a button. This is an aspect you have to implement in the main loop by explicitly invoking the function CoreRoot__DriveKeyboardHitting() every time you detect taht the user has pressed/released a button.

You can, for exampe, map the four buttons to the keys User1, User2, User3 and User4 (see also). Then when you detect in the main loop that the user has pressed or released the first button, you call the function CoreRoot__DriveKeyboardHitting() as demonstrated below:

if ( Button_1_Pressed )
  events |= CoreRoot__DriveKeyboardHitting( rootObject, CoreKeyCodeUser1, 0, 1 );

if ( Button_1_ReLeased )
  events |= CoreRoot__DriveKeyboardHitting( rootObject, CoreKeyCodeUser1, 0, 0 );

SimIlarly, you call the functions when other buttons are pressed/released by using the corresponding key codes. Once the function is called, the corresponding event is propagated through the GUI application to the actually focused GUI component and there it can be processed.

Best regards

Paul Banach

by
This is an answer I was looking for. Thanks Paul.
0 votes
by

Hi Michal,

Please have a look at this and this chapter, found at our knowledge base.

Br,
Manuel

Embedded Wizard Website | Privacy Policy | Imprint

...