Re: Which widget id triggered the event?
- From: MICHAEL MCGINN <mmcginn rogers com>
- To: gtk-perl-list gnome org
- Subject: Re: Which widget id triggered the event?
- Date: Fri, 13 Apr 2007 07:40:42 -0700 (PDT)
Sorry but I unknowingly had the solution but didn't properly test.
Solution
my $widget = Gtk2->get_event_widget(Gtk2->get_current_event);
if ($widget == $button1) {
$action = "";
} elsif ($widget == $menuitem) {
$action = "";
}
----- Original Message ----
From: MICHAEL MCGINN <mmcginn rogers com>
To: gtk-perl-list gnome org
Sent: Friday, April 13, 2007 8:59:52 AM
Subject: Which widget id triggered the event?
Hi,
Is there any way to figure out which widget id triggered an event?
An example
I have a common function that could be triggered by either a button click, menuitem, popup menuitem, etc...
Depending on what widget was used I want call the same function, detemine which widget, then process accordingly. Based on which widget I would perform all or a subset of the function.
I've looked into the Gtk2::main and Gtk2::Widget methods and they provide the event widget (GtkMenuItem) and complete path (GtkWindow.GtkMenu.GtkMenuItem) but I would need the id of the menu item (ex: "menu name1" or "menu name 2") in order to process accordingly.
The way I do it now is to have the signal handler from the widget call the function and pass it what it needs.
Thanks in advance,
Michael
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]