How do I intercept keys in a Gtk::Entry widget?



Hey All,

I'd like to process the right arrow key in a Gtk::Entry widget (so, for
instance, if the cursor is at the rightmost insert position, I'd like to do
something special) but if I connect to the signal keypress event as so:

// LXWidgetEntry inherits from Gtk::Entry
LXWidgetEntry::LXWidgetEntry()
{
    signal_key_press_event().connect(sigc::mem_fun(*this,
&LXWidgetEntry::OnKeypress));
}

bool LXWidgetEntry::OnKeypress(
    GdkEventKey* event) // [in] event from the system (with key, state,
etc.)
{
    if (event->keyval == GDK_Right)
    {  // Do my thing here

    }
    return false;
}

I never get the right arrow key (I can get other keys, such as Tab, but not
keys the entry control uses).

Once I get the key, how do I either let the widget continue to handle the
key in some of the cases?

Thanks in advance!

-Garth
-- 
Garth Upshaw
Garth's KidStuff



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