Setting window focus


bzar

A Commando
Joined
Sep 22, 2008
Messages
4,500
Location
Finland
Website
Visit site
It seems my platformer compo entry has a problem. The game window does not have focus when the PND is run, so all the input events go somewhere else until the screen is tapped to set focus. The PND is generated with Sebt3's toolchain and uses the default startup script. Is there any way I can ensure focus for the game window a startup?
 
Answering myself here. I'm using Qt, so I tried to find a cross-platform way of doing this. For some reason I've missed QWidget::activateWindow completely! So here's the full dance:



Code:
w.setFocus();       // ensure focus on right widget inside application

w.activateWindow(); // ensure window focus on this application

w.raise();          // ensure this window is on top


Almost dipped into XLib for this. Close save :p
 
Back
Top