Jump to content

[SOLVED] Input and focus handling


photo

Recommended Posts

Hello!

 

I have some problems to archive the following:

 

1. Shortcuts for alt + Fx keys

 

Currently it seems impossible to catch alt+f4 and such shortcuts.

I using engine.gui.setKeyPressCallback() and engine.controls.setKeyPressCallback() to get the key press events.

 

At least under linux in windowed mode, all alt + Fx and alt + tab are not forwarded to the engine.

Is there a way to catch these shortcuts?

 

2. Windowed mode and mouse grab

 

Is there a way to detected if the focus is lost in the engine window? Currently if you use alt+tab and the mouse was grabbed, the mouse cursor hangs in the middle of the engine window. Interaction with other programs or the desktop is in this case not possible. Are there any events I can catch to set mouse grab to disabled?

 

 

Thanks,

Manuel

Link to comment

Hi Manuel!

 

Both of these cases were handled by internal Unigine::App implementation so you can't get them properly in a "good way", though we have some script API such as engine.app.setMouseGrab.

 

So I recommend you to implement your own App class on C++ side by inheriting from Unigine::App class. That way you'll be able to get every OS message and respond properly.

 

Please refer to this article: https://developer.unigine.com/en/docs/1.0/cpp_api/usage/app

Link to comment

Hello unclebob!

Thanks a lot for the links. I will try it out.

The main problem with alt+fX is that alt+f4 closes the app under Linux but not windows. (Not sure if this is a bug or designed this way)

We currently use engine.app.setMouseGrab but there seems no way to release it at the right time. (User is tabbing out or switching to another application, so the grab couldn't be released on any engine event)

I think both should be possible with the app class but a direct integration into the engine would be nice. (The mouse grab can really be annoying in the view of usability, if the user is trapped inside the engine window)

Greets
Manuel

Link to comment

Hello again, Manuel.

 

I also want to say some words about second question. Mouse handling (such as grabbing and setting its position in the middle of the window) is done inside Unigine's systemUpdate function which is usually called in client system script.

 

So one more thing you can try is to disable its logic by putting this line to your system script:

#define MOUSE_USER 

Please also read this topic: https://developer.unigine.com/forum/topic/3029-how-to-disable-the-cursor-hidden-and-option-dialog/

Link to comment
×
×
  • Create New...