Re: How to simulate keypress event for "page down" keyboard button ?

Govinda Parida wrote:

Hi, I have added a Gtk::TreeView control in a Gtk::Window and at the right side of the treeview, I have added a Gtk::Button. when this button is clicked the keypress event to the "page down" key should be generated to view the next page of treeview. How do I generate keypress event for "page down" key. please give me some clues.

You have to create a GdkEventKey, something like that:

void Foo:bar() // handler for signal_clicked()
        <YOUR TREEVIEW>.grab_focus(); // essential

        guint keyval = GDK_Page_Down;

        GdkKeymapKey* keys;
        gint n_keys;
	// Note: GdkEvent is an union
        GdkEvent* event = gdk_event_new(GDK_KEY_PRESS);
        ((GdkEventKey*)event)->window =
                             <YOUR TREEVIEW>get_window()->gobj();
        ((GdkEventKey*)event)->send_event = TRUE;
        ((GdkEventKey*)event)->time = GDK_CURRENT_TIME;
        ((GdkEventKey*)event)->state = GDK_KEY_PRESS_MASK;
        ((GdkEventKey*)event)->keyval = keyval;
        ((GdkEventKey*)event)->hardware_keycode = keys[0].keycode;
        ((GdkEventKey*)event)->group = keys[0].group;

//      Or, more gdkmm-ish:
//      Gdk::Event(event).put();

Anyway it's GDK stuff, I don't know how to do that in gdkmm..
Take a look to GDK reference for more info.



gtkmm-list mailing list
gtkmm-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]