[immodule-qt] QInputContext Implementation
manish.s.sharma at nokia.com
manish.s.sharma at nokia.com
Thu Aug 7 08:07:15 PDT 2008
Hi,
Thanks for the reply.
My goal is to write a plugin for a text widget.
Plugin will do some kind of pre-processing on the key & mouse presses on
the text widget.
Current status of my work:
Problem was that I was not able to get events in
QInputContext::filterEvent function. After some debugging i figured out
the problem. I am using QTextEdit as my text editor. And if we enable
inputcontext for the editor, Events will come from
QTextControlPrivate::mousePressEvent to QInputContext::mouseHandler(). I
found some code related to inputcontext in
QTextControlPrivate::mousePressEvent functions. Below is the code:
void QTextControlPrivate::mousePressEvent(..........
.
.
.
.
#if !defined(QT_NO_IM)
QTextLayout *layout = cursor.block().layout();
if (contextWidget && layout &&
!layout->preeditAreaText().isEmpty()) {
QInputContext *ctx = contextWidget->inputContext();
if (!ctx && contextWidget->parentWidget())
ctx = contextWidget->parentWidget()->inputContext();
if (ctx) {
QMouseEvent ev(QEvent::MouseButtonPress,
contextWidget->mapFromGlobal(globalPos), globalPos,
button, buttons, modifiers);
ctx->mouseHandler(cursorPos - cursor.position(), &ev);
}
if (!layout->preeditAreaText().isEmpty())
return;
}
#endif
.
.
.
}
In above code on mouse press event input context's moseHandler function
is called. And similar implementation is not there for keypress. So I
replicated above code with some changes in
QTextControlPrivate::keyPressEvent(QKeyEvent *e) function. to enable
filterEvent call.
void QTextControlPrivate::keyPressEvent(QKeyEvent *e)
{
Q_Q(QTextControl);
//++ Added code for input context to work..!
#if !defined(QT_NO_IM)
QTextLayout *layout = cursor.block().layout();
if (contextWidget && layout &&
!layout->preeditAreaText().isEmpty()) {
QInputContext *ctx = contextWidget->inputContext();
if (!ctx && contextWidget->parentWidget())
ctx = contextWidget->parentWidget()->inputContext();
if (ctx) {
ctx->filterEvent(e); // calling filterEvent function.
}
}
#endif
//-- Added code for input context to work..!
With above changes i am able to get the events in filterEvent functions.
But i am not sure that whethere this is the correct approach, if it is
the correct approach then QTextControlPrivate implementation is not
complete. Please correct me if I am wrong. If possible please explain me
the architecture.
Thanks & Regards,
Manish
>-----Original Message-----
>From: ext Daisuke Kameda [mailto:kaminmat at cc.rim.or.jp]
>Sent: Thursday, August 07, 2008 5:33 AM
>To: Sharma Manish.S (Nokia-D-MSW/Bangalore)
>Cc: immodule-qt at lists.freedesktop.org
>Subject: Re: [immodule-qt] QInputContext Implementation
>
>I'm sorry I was late.
>
>But, probably you mistake understanding about architecture of immodule.
>Please tell me your goal or purpose.
>
>
>manish.s.sharma at nokia.com wrote:
>> Hi,
>>
>> Thanks for the reply. I will definitely wait for your reply.
>Till that
>> time I am sending you my progress on the same.
>> I still have those questions open in my previous mail.
>>
>> Eagerly waiting for this weekend.
>>
>> Thanks & Regards,
>> Manish
>>
>>> -----Original Message-----
>>> From: ext Daisuke Kameda [mailto:kaminmat at cc.rim.or.jp]
>>> Sent: Tuesday, July 29, 2008 6:12 PM
>>> To: Sharma Manish.S (Nokia-D-MSW/Bangalore)
>>> Cc: immodule-qt at lists.freedesktop.org
>>> Subject: Re: [immodule-qt] QInputContext Implementation
>>>
>>> Hi,
>>>
>>> I couldn't take time to study and consider.
>>>
>>> I didn't use Qt/Win, so I can't answer correctly.
>>> But, probably it is necessary to explain architecture about
>immodule
>>> I feel.
>>>
>>> Please wait until next week end.
>>>
>>>
>>> manish.s.sharma at nokia.com wrote:
>>>> Hi,
>>>>
>>>> Thanks for the response.
>>>>
>>>> I am very new to Qt and I am really sorry for posting such
>>> an immature
>>>> code on forum. As suggested by you I just had a look at the
>>>> QXIMInputContext and here are some of my observations and
>questions.
>>>>
>>>> A) Widget to InputContext conversation:
>>>> 1) I think there is some callback we have to introduce
>>> for the widget
>>>> to inform input context about different states. Are those
>>>> callback functions are already implemented? Or are
>>> those functions we
>>>> have to implement based on Operating System we are using?
>>>>
>>>> 2) What is the use of filterEvent functions? From the trolltech
>>>> documents it seems that we should get callbacks for the
>>> keypress at this
>>>> function, But I am not getting any callbacks. Any
>>> guess on this?
>>>> B) InputContext to Widget conversation:
>>>> 1) I am able to send some events from InputContext to
>>> Widget with
>>>> sendEvent function ( with unexpected behavior :) ). Is there any
>>>> other way to send information to Widget?
>>>>
>>>> Please correct me if I am wrong.
>>>>
>>>> (I have qt-win-opensource-src-4.4.0-rc1 version installed
>in my PC.)
>>>>
>>>> Awaiting for the response.
>>>>
>
>
More information about the immodule-qt
mailing list