Re: gtkEventBox and wimp
| From: | Jake Cobb | Date: | Thu, 24 May 2007 15:45:11 +0000 |
| Subject: | Re: gtkEventBox and wimp | ||
| References: | 1 2 3 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-7840@lists.php.net to get a copy of this message | ||
Hello,
The events "bubble" through, so you should see that both get
called when you click the child. For this short example:
<?php
function box1clicked() { print("box1 clicked\n"); }
function box2clicked() { print("box2 clicked\n"); }
$wnd = new GtkWindow();
$box1 = new GtkVBox();
$ebox1 = new GtkEventBox();
$label1 = new GtkLabel("Box1");
$box2 = new GtkVBox();
$ebox2 = new GtkEventBox();
$label2 = new GtkLabel("Box2");
$ebox1->add($box1);
$ebox2->add($box2);
$box1->pack_start($label1);
$box2->pack_start($label2);
$box1->pack_start($ebox2);
$wnd->add($ebox1);
$wnd->connect_simple("destroy", array("gtk", "main_quit"));
$ebox1->connect_simple("button-press-event", "box1clicked");
$ebox2->connect_simple("button-press-event", "box2clicked");
$wnd->show_all();
Gtk::main();
?>
Clicking where you see the "Box1" label will give:
box1 clicked
Clicking where you see the "Box2" label will give:
box2 clicked
box1 clicked
So, the first box's handler is called when you click the second box,
but only after the second box's handler. If a function returns true,
it breaks the event chain. So if we change our function to:
function box2clicked() { print("box2 clicked\n"); return true; }
Then clicking the "Box2" label will give:
box2 clicked
Returning true prevents the second handler (box1clicked) from being called next.
If all of your button-press-event handlers return true, then you will always know
that the event box corresponding to the function being called is the deepest
in the hierarchy for that event. In the above example, you would know that
box1clicked() being called means box1 was clicked and not via an event-receiving child.
-Jake Cobb
thomas favennec wrote:
Hi, Thanks Jake. This is for my Gul 2.0 project (http://gul.redsofa.net) a Xul parser for PhpGtk 2. $ebox->set_visible_window(false) is perfect !!! I have an other problem with event box. I try to create a wysiwyg editor like Glade for Xul (based on Gul 2.0) But i don't understand when Glade (the glade sofware) can use clickable boxes. To do that, i use gtk2 event box (with button-press-event) into all my boxes. But if i have one box into other box ( box1 + eventbox1 into box2 + eventbox2 ) : - When i click on box1 : the box1 event is called - When i click on box2 : the box1 event is called :-( I can't detect when all box is clicked. Do you have one idea ? Thanks. Thomas. ----- Original Message ----- From: "Jake Cobb" <jake@lyrehc.com> To: "thomas favennec" <webmaster@redsofa.net> Cc: <php-gtk-general@lists.php.net> Sent: Wednesday, May 23, 2007 6:44 PM Subject: Re: [PHP-GTK] gtkEventBox and wimpHello, You can turn off the visible window setting of the event box(es) to get rid of the background. I had this same problem with the Wimp engine running in Windows, I'm not sure why it does that. Some of the other theme settings can be changed by modifying the gtkrc file in the theme's folder. For example, enabling alternating row colors on GtkTreeView objects which Wimp disables by default. Anyway, for every event box: $event_box->set_visible_window(false); Better yet, if you're using Glade you can just set Visible Window to "No" and not have to change your code at all. -Jake Cobb thomas favennec wrote:Hi, I've a problem with the " wimp " engine and EventBox in Window Xp. I must use eventbox in my project. If i use Evenbox into GtkNotebook (tabs and/or page of notebook), the eventbox color is not white (like tab's background and page's background in the notebook). Screenshot here: http://www.redsofa.net/images/eboxproblem.png Someone knows create a transparent eventbox ? Best reguards Thomas.-- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php