FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

EventBox and accelerators

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
Mitu



Joined: 22 Sep 2009
Posts: 59
Location: Poland

PostPosted: Fri Feb 26, 2010 8:02 am    Post subject: EventBox and accelerators Reply with quote

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
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Fri Feb 26, 2010 1:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mitu



Joined: 22 Sep 2009
Posts: 59
Location: Poland

PostPosted: Fri Feb 26, 2010 2:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Sat Feb 27, 2010 6:08 am    Post subject: Reply with quote

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
View user's profile Send private message
Mitu



Joined: 22 Sep 2009
Posts: 59
Location: Poland

PostPosted: Sat Feb 27, 2010 7:54 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group