[Qt-interest] [Qt/Mac] Stuck with user focus
Frank Mertens
frank at cyblogic.de
Sat Jan 24 21:30:18 CET 2009
So, it behaves like a Chinese input widget...
Nice problem, I would still try to fiddle around with
the window flags then. If there is no combination working
only a troll knows the answer -- certainly must be bug
in Qt (qt-bugs at trolltech.com).
Another strange idea: Try to catch the mouse press event
by installing an event filter on qApp and eat it up
before it hits your on-screen window...
But probably this won't help, if the focus
acquisition is already handled by the window system.
(Inspecting QFocusEvent::reason() should tell more.)
Sergey Uspensky wrote:
> Sorry ive written it in such a way)
>
> I dont want the keyboard widget to receive focus
>
> When I click on my keyboard widget to select letters it dont get focus now (
> thanks to your help!)
>
> But when i click on my keyboard widget, the focus also dissapears from
> other system-wide application which had input focus before - that is the
> problem for me.. i cant paste letters to that app %)
>
> 2009/1/24 Frank Mertens <frank at cyblogic.de>
>
>> Why you want to have the on-screen keyboard widget receive keyboard
>> focus? It displays keys or makes the user click on them...
>> Probably I don't get the problem here.
>>
>> Sergey Uspensky wrote:
>>> Hmmm - thats Qt4.4 on OS X yes)
>>>
>>> But this dont do the trick - the window don't get focus when i click on
>> it
>>> but focus from another application which intended to get letters from
>>> keyboard disappears too... and I don't know how to bring it back there
>>>
>>> Im thinking to make it in X style - XInternAtom(display, "WM_TAKE_FOCUS",
>>> true) and XFree() - like in linux version)) since the OS X have XQuartz
>>> afaik
>>>
>>> 2009/1/24 Frank Mertens <frank at cyblogic.de>
>>>
>>>> Try again:
>>>>
>>>> OnScreenKeyboard::OnScreenKeyboard()
>>>> : QWidget(0)
>>>> {
>>>> setWindowFlags(Qt::Tool|Qt::FramelessWindowHint);
>>>> setFocusPolicy(Qt::NoFocus);
>>>> }
>>>>
>>>> void OnScreenKeyboard::mousePressEvent()
>>>> {
>>>> // handle click on my on-screen keys
>>>> }
>>>>
>>>> That's Qt44 on OS/X? At least for me it works;)
>>>>
>>>> --
>>>> Frank
>>>>
>>>> Sergey Uspensky wrote:
>>>>> Thanks for help!!
>>>>>
>>>>> yep i've tried Qt::Tool, Qt::FramelessWindowHint but with no use -
>>>>>
>>>>> the window don't get focus when i click on it, but focus from other
>>>>> application dissapears too (on desktop?).
>>>>>
>>>>> if it is focusProxy() then what widget should i setup it?
>>>>>
>>>>> thanks again,
>>>>>
>>>>> Sergey
>>>>>
>>>>>
>>>>> 2009/1/24 Frank Mertens <frank at cyblogic.de>
>>>>>
>>>>>> Oh, focus handling can run you mad!-)
>>>>>> Watch out window flags Qt::Tool, Qt::FramelessWindowHint for your
>>>>>> on-screen keyboard.
>>>>>> Maybe QApplication::focusChanged(QWidget*,QWidget*) [signal] and
>>>>>> QWidget::focusProxy() may also be your friends in tricking the
>>>>>> focus policy.
>>>>>> The undesired effects of your mouse clicks you could filter with
>>>>>> an event filter ala QWidget::eventFilter().
>>>>>> More tricks I don't know.
>>>>>>
>>>>>> Good luck,
>>>>>> --
>>>>>> Frank
>>>>>>
>>>>>> Sergey Uspensky wrote:
>>>>>>> Hello guys!
>>>>>>> Im developing an application for Mac OS Leopard on Qt - kinda
>> onscreen
>>>>>>> keyboard.
>>>>>>> The thing is I need to make MainWindow of the application not
>> accepting
>>>>>>> keyboard focus (user focus) when user clicks on it choosing possible
>>>>>> letters
>>>>>>> (keep it always inactivated).
>>>>>>>
>>>>>>> I have already tried both:
>>>>>>>
>>>>>>> in Qt 4.4 (it uses Carbon as far as i know)
>> 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 Carbon or Qt?
>>>>>>>
>>>>>>> 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 would do the trick?
>>>>>>>
>>>>>>> Any help will be appreciated.
>>>>>>>
>>>>>>> TIA,
>>>>>>> Sergey
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>> ------------------------------------------------------------------------
>>>>>>> _______________________________________________
>>>>>>> Qt-interest mailing list
>>>>>>> Qt-interest at trolltech.com
>>>>>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>>>> _______________________________________________
>>>>>> Qt-interest mailing list
>>>>>> Qt-interest at trolltech.com
>>>>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>>>>
>>>>>
>>>> _______________________________________________
>>>> Qt-interest mailing list
>>>> Qt-interest at trolltech.com
>>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>>
>>>
>>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
>
More information about the Qt-interest-old
mailing list