View previous topic :: View next topic |
Author |
Message |
Mitu
Joined: 22 Sep 2009 Posts: 59 Location: Poland
|
Posted: Fri Feb 26, 2010 8:02 am Post subject: EventBox and accelerators |
|
|
I want to invoke the button-release-event signal from accelerator. Unfortunately this: Code: | ebox.addAccelerator("button-release-event", accelGroup, GdkKeysyms.GDK_q, ModifierType.CONTROL_MASK, AccelFlags.VISIBLE); | does't work. I see the warning: Code: | (dcoder:3808): Gtk-WARNING **: /build/buildd/gtk+2.0-2.18.3/gtk/gtkwidget.c:4253: widget `GtkEventBox' has no activatable signal "button-release-event" without arguments |
What's wrong here? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Fri Feb 26, 2010 1:34 pm Post subject: |
|
|
That because "button-release-event" is not an Action signal, you could try to hook it up to the activate signal of the corresponding menu item. |
|
Back to top |
|
|
Mitu
Joined: 22 Sep 2009 Posts: 59 Location: Poland
|
Posted: Fri Feb 26, 2010 2:06 pm Post subject: |
|
|
Is any workaround possible? I've written a custom widget, which performs action on mouse release... Do I have to modify the widgt? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sat Feb 27, 2010 6:08 am Post subject: |
|
|
You can try this, where widget is the Widget that receives the key combo.
Code: | widget.addOnKeyPress(&keyPerssed);
bool keyPerssed(GdkEventKey* e, Widget w)
{
if ( e.state == ModifierType.CONTROL_MASK && e.keyval == GdkKeysyms.GDK_q )
{
ebox.onButtonReleaseEvent(new GdkEventButton);
return true;
}
return false;
} |
If the event of your custom widget uses the GdkEventButton structure, you might want to fill it with something usefull. |
|
Back to top |
|
|
Mitu
Joined: 22 Sep 2009 Posts: 59 Location: Poland
|
Posted: Sat Feb 27, 2010 7:54 am Post subject: |
|
|
That won't work when numlock is on. This:
Code: | e.state == ModifierType.CONTROL_MASK |
fails, because numlock mask changes the value. Need to extract current bit.
I've done this:
Code: | e.state & ModifierType.CONTROL_MASK && e.keyval == GdkKeysyms.GDK_q |
And it works now. Thank you |
|
Back to top |
|
|
|