Jump to content

[SOLVED] Mouse event ignored when changing focus


photo

Recommended Posts

Hi,

Got another issue with the UI. It seems that when the main window receives focus, it ignores any mouse event from that frame. We experienced this issue in combination with a popup window (made with the Interface plugin) which shows some information for the selected object. When this popup as focus, the user needs to click twice to select a different object in the 3D view. I managed to create a simple repro script, tested in an empty 2.12 project with just the Interface plugin added to it:

int init() {
    engine.controls.setMouseHandle(MOUSE_HANDLE_SOFT);

    InterfaceWindow iw = new InterfaceWindow(INTERFACE_WINDOW_TITLE);
    WidgetButton wb1 = new WidgetButton(engine.getGui(), "Click me first");
    iw.setHidden(false);
    iw.setWidget(wb1);

    WidgetButton wb2 = new WidgetButton(engine.getGui(), "Click me second");
    engine.gui.addChild(wb2, GUI_ALIGN_CENTER);
	
    return 1;
}

Simply run this script, press the button which says "Click me first" which causes the interface window to have focus, and then click the "Click me second" button located on the main window. You should notice the button 'animation' of being pressed down does not happen on the first click, but only on the second click. It's not limited to just Widgets, if I logspam the value of engine.app.getMouseButton() it also prints 0 to the console on the first click.

I also tested this on the Unigine 2.5 SDK and it worked fine there, so I suspect the new AppWindow (we noticed this was refactored some versions ago) causes this?

Link to comment

Could you please check if this patch will work?

	source/engine/framework/AppSDL.cpp


	SDL_SetMainReady();
	if (SDL_Init(SDL_INIT_VIDEO) < 0)
		Unigine::Log::fatal("AppSDL::AppSDL(): SDL_Init() %s\n", SDL_GetError());
	SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); // add this line

	// create RenderContext
	const auto &video_app = engine.engine->getVideoApp();

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • silent changed the title to [SOLVED] Mouse event ignored when changing focus
  • 1 month later...

We decided to revert this fix, because it introduces other issues when application was out of focus.

You can patch the engine manually on your side (source/engine/framework/AppSDL.cpp):

source/engine/framework/AppSDL.cpp
AppSDL::AppSDL() ...

if (SDL_Init(SDL_INIT_VIDEO) < 0)
	Unigine::Log::fatal("AppSDL::AppSDL(): SDL_Init() %s\n", SDL_GetError());

SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); // add this line

Proper solution would be to completely rewrite Interface plugin to use new SDL pipeline (that we eventually will do).

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...