Method KeyInput doesn't work on ComboBox

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Method KeyInput doesn't work on ComboBox

lijian-7
Hi all,

I am working on writer now, and I came accross a problem.
Truly hope to get help from here.

I newed a dialog which contains a ComboBox in writer.
I want to do some special keyinput operations for the ComboBox.
So I derived a control from ComboBox named SwEncloseComboBox,
and override the virtual method ::KeyInput of ComboBox which is
derived from class Edit.

This question is : When I do KeyInput, the method SwEncloseComboBox::KeyInput
will not be called. But the method Edit::KeyInput will be directly called.
I don't know why.

And I found that the method keyinput of all ComboBox derivations in writer didn't
work at all. But KeyInput of the derivations of class Edit works all right.

Hope somebody can help me. I am really need to implement this keyinput for
SwEncloseComboBox.

Thank you very much in advance and looking forward to your help.

regards,
2009-11-12



lijian
Reply | Threaded
Open this post in threaded view
|

Re: Method KeyInput doesn't work on ComboBox

Malte Timmermann
Hi lijian,

this is because the ComboBox is a control combined by many other
controls: edit, listbox, ...

There is an extra inner edit that has the focus and gets the normal
events. That's why your derived edit doesn't get the events, because it
is not derived from the inner edit.

You can use long Window::PreNotify( NotifyEvent& ) to get the event
before it's passed to the "normal" event handler, and you can even catch it.

With long Window::Notify( NotifyEvent& ) you get it after it was handled
in the normal event handler.

(Pre)Notify bubbles up the window hierarchy, until some implementation
returns something != 0, which means the event was catched/handled and
shouldn't bubble anymore.

If you don't handle it, make sure to call the base class.

See svtools/source/edit/svmedit.cxx as an example.

HTH,
Malte.



lijian wrote, On 11/12/09 06:57:

> Hi all,
>
> I am working on writer now, and I came accross a problem.
> Truly hope to get help from here.
>
> I newed a dialog which contains a ComboBox in writer.
> I want to do some special keyinput operations for the ComboBox.
> So I derived a control from ComboBox named SwEncloseComboBox,
> and override the virtual method ::KeyInput of ComboBox which is
> derived from class Edit.
>
> This question is : When I do KeyInput, the method SwEncloseComboBox::KeyInput
> will not be called. But the method Edit::KeyInput will be directly called.
> I don't know why.
>
> And I found that the method keyinput of all ComboBox derivations in writer didn't
> work at all. But KeyInput of the derivations of class Edit works all right.
>
> Hope somebody can help me. I am really need to implement this keyinput for
> SwEncloseComboBox.
>
> Thank you very much in advance and looking forward to your help.
>
> regards,
> 2009-11-12
>
>
>
> lijian
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Method KeyInput doesn't work on ComboBox

lijian-7
In reply to this post by lijian-7
Hi Malte,

Thank you very much for your clear and detaied explanations on this problem.

I have solved this porblem with your help. I override the PreNotify method for
my own ComboBox and make the method return 1 when it satisfies my conditions,
and then I can control the keyinput as I want.

Thank you very much and best wished to you.

regards,
2009-11-13



lijian