PDA

View Full Version : Qt/Mac - Stuck with user focus



sergant
23rd January 2009, 23:30
Hello guys
Im developing an application for Mac OS X Leopard on Qt - kinda onscreen keyboard.
The thing is I need to make QMainWindow of the application not accepting keyboard focus (user focus) when user clicks on it choosing possible letters (keep it always inactivated). And then send keys to any other apps

I have already tried both:

in Qt setFocusPolicy(Qt::NoFocus) - the window stops getting focusEvents but still grabs keyboard focus
and
in Carbon setting kHIWindowBitNoActivates and kWindowNoActivatesAttribute for this WindowRef

Both variants didnt work.
Are there any workarounds in Qt or any for Carbon?

Afterwards when the window is off-focus I need to send the key to other application(system wide) which currently has user focus. I think CGEventCreateKeyboardEvent and then CGEventPost in Carbon would do the trick or are there any options in Qt?
Im using Qt 4.4 which still utilizes Carbon

Any help will be appreciated..

TIA,
Sergey

sergant
24th January 2009, 08:56
Oop found a similar problem
http://www.qtcentre.org/forum/f-qt-programming-2/t-discussion-about-developing-an-onscreen-keyboard-in-qt-17816.html

But there it is about X11. It can be done like

Atom atom = XInternAtom(display, "WM_TAKE_FOCUS", true);
XFree(atom);

How to make the same thing in mac?