Overriding/Replacing default signal handler
- From: Tihomir Mitkov <mitkovtihomir gmail com>
- To: gtk-perl-list gnome org
- Subject: Overriding/Replacing default signal handler
- Date: Sat, 15 Apr 2017 17:02:13 +0300
Hello,
I'm playing around with Gtk menus in Perl. I would like to end up with a custom drop down menu containing complex widgets, not simply menu items. For that purpose I would display a custom built window and make it behave like a menu (e.g. grabbing keyboard/mouse during its lifetime). I am mostly done with that but I can't figure out how to replace the default handler for the activate signal.
I tried with conventional signal connecting and stopping propagation from inside the handler (code simplified to make it more readable)
$this->menuItem->signal_connect(activate => sub {$this->togglePopup()});
sub togglePopup
{
my $this = shift;
$this->menuItem->signal_stop_emission_by_name('activate');
return 1;
}
From what I understood connecting handler the usual way would make it be called before the default handler, so stopping the emission from my handler makes sense. However the default handler still gets called. Even returning TRUE doesn't help. I tried with signal_connect_after with no luck.
Then I tried another approach and made a custom MenuItem widget which overrides the activate signal handler
package CustomMenuItem;
use Gtk3;
use Glib::Object::Subclass
Gtk3::MenuItem,
signals =>
{
activate_item => \&on_activate
}
;
However, the custom handler seems to be ignored and instead the default handler is still called.
Thanks,
Tihomir Mitkov
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]