Re: Howto: Default buttons?

From: Date: Thu, 01 Jul 2004 20:19:59 +0000
Subject: Re: Howto: Default buttons?
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4684@lists.php.net to get a copy of this message
The application gtk.php included with the php-gtk sources has an answer for this and many other good sample features. The code looks like this: $button = &new GtkButton('close'); $button->connect('clicked', 'close_window'); $main_vbox->pack_start($button); $button->set_flags(GTK_CAN_DEFAULT); $button->grab_default(); $button->show(); - Frank > In most apps, there's a "default button" to a dialog box. I have a picture of > such a critter at http://charterworks.net/default_button.jpg > using Gimp 1.2 > (so it's apparently part of GTK) > > Notice that the "Close" button has a larger border around it - if I just press > "Enter" on the keyboard, this is the button that is pressed. > > I've tried to get this to work with set_relief, grab_focus, grab_default, > draw_default, no dice. > > How could I modify this little script to do this in PHP-GTK? > > <? > > Function ShowAction($widget, $action) > { > echo $action."\n"; > } > > $win=&New GtkWindow(); > > $button1=&New GtkButton('Not Default"); > $button1->Connect('clicked', 'showaction', 'Not Default'); > > $button2=&New GtkButton("Default"); > $button2->Connect('clicked', 'showaction', 'Default'); > > $bbox=&New GtkHBox(); > $bbox->Pack_Start($button1); > $bbox->Pack_Start($button2); > > $win->Add($bbox); > $win->Show_All(); > > ?> > -- > "I kept looking around for somebody to solve the problem. > Then I realized I am somebody" > -Anonymous > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.gtk.general (#4684) next »