[Qt-interest] [Qt/Mac] Stuck with user focus

Frank Mertens frank at cyblogic.de
Sat Jan 24 20:31:22 CET 2009


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




More information about the Qt-interest-old mailing list