Re: Tab pressing
- From: Bob Caryl <bob fis-cal com>
- To: doug dooglio net
- Cc: gtkmm-list gnome org
- Subject: Re: Tab pressing
- Date: Tue, 13 Dec 2005 14:43:50 -0600
That is a really good question, and frankly I don't know the answer.
The reason I was using the Gtk::Main::signal_key_snooper in my
applications was to invoke my help browser, and the only way I could
find to get the keystroke regardless of what widget had the focus was to
use that signal. Paul's (dreadful idea) message before expresses a
concern that is admittedly valid, e.g. it smacks of using a global
variable, but if one is careful in its implementation, it should work.
That's why I tested for a GdkEventKey::type of GDK_KEY_PRESS along with
GdkEventKey::keyval so I'd only perform the desired action when the key
went down, and not when it came back up again.
Bob
R. Douglas Barbieri wrote:
>Wouldn't it work to listen to the keypress event in the container
>widget of the controls he wants to tab through? Or do the child
>widgets grab up the events before you get them?
>
>If that's the case, the child widgets would still have to listen to
>their own key_press events, but then pass on tabs to the containing
>widget.
>
>On 12/13/05, Bob Caryl <bob fis-cal com> wrote:
>
>
>>R. Douglas Barbieri wrote:
>>
>>"You can also assign a keypress signal to any widget: signal_key_press_event()."
>>
>>
>>This is true, but I think Volosatov is looking for a way for forces his
>>widgets to duplicate the behavior they exhibit when they receive a
>>GDK_Tab keystroke, to wit: The next widget in the tab order grabs
>>focus. If Volosatov were to connect to all his widget's
>>signal_key_press_event(s) I suppose he could artificially duplicate this
>>behavior using grab_focus calls. . . seems kinda kludgey to me.
>>Nevertheless, if kludgey is the only way to do it, so be it.
>>
>>Bob
>>
>>R. Douglas Barbieri wrote:
>>
>>
>>
>>>You can also assign a keypress signal to any widget: signal_key_press_event().
>>>
>>>On 12/13/05, Bob Caryl <bob fis-cal com> wrote:
>>>
>>>
>>>
>>>
>>>>First you must intercept the <Enter> keystroke event before it is
>>>>propagated to the widgets contained in your application window(s). To
>>>>do this, you must connect your own callback slot to
>>>>Gtk::Main::signal_key_snooper like this:
>>>>
>>>>Gtk::Main::signal_key_snooper().connect(sigc::mem_fun(*this,&YourClass::on_enter_key_pressed));
>>>>
>>>>This callback slot will receive a Gtk::Widget pointer and a GdkEventKey
>>>>pointer; so you can determine whether or not the enter key has been
>>>>pressed. I attempted to use gtk_propagate_event to propagate a TAB
>>>>keypress, but I was unable to get it to work. The code below definitely
>>>>intercepts the <Enter> keystroke.
>>>>
>>>>// code begins
>>>>YourClass::on_enter_key_pressed(Gtk::Widget* widget, GdkEventKey *keyevent)
>>>>{
>>>>
>>>> if(keyevent->keyval == GDK_Enter && keyevent->type == GDK_KEY_PRESS)
>>>> {
>>>>
>>>> }
>>>>
>>>> return 1;
>>>>
>>>>}
>>>>// code ends
>>>>
>>>>Disclaimer: I could not find anything on what the return value from the
>>>>callback should be or why.
>>>>
>>>>Can anyone help with code to propagate a tab key press for Volosatov?
>>>>
>>>>Bob
>>>>
>>>>Volosatov Alexander wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>I need when user press <Enter>, emit <Tab> pressing.
>>>>>What function I must use and how?
>>>>>
>>>>>Alex
>>>>>_______________________________________________
>>>>>gtkmm-list mailing list
>>>>>gtkmm-list gnome org
>>>>>http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>_______________________________________________
>>>>gtkmm-list mailing list
>>>>gtkmm-list gnome org
>>>>http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>>>
>>>>
>>>>
>>>>
>>>>
>>>--
>>>R. Douglas Barbieri
>>>doug dooglio net
>>>
>>>
>>>
>>>
>>>
>
>
>--
>R. Douglas Barbieri
>doug dooglio net
>
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]