[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 post

Bemined

Yes, AppWindow refactoring may be the root cause. I've successfully reproduced this behavior.

Hope the fix will not be very complex and we can include it in 2.13 SDK update.

Thanks!

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

Link to post

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 post

Seems to work perfectly now, thanks!

Link to post
  • silent changed the title to [SOLVED] Mouse event ignored when changing focus