Re: Howto: Default buttons?

From: Date: Fri, 02 Jul 2004 00:07:19 +0000
Subject: Re: Howto: Default buttons?
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4686@lists.php.net to get a copy of this message
Ben - I do this all the time on our message windows. Couple things I would say: 1. This may not be relevant, but you have a mismatched quote on button1; s/b 'Not Default'. Probably a typo coming to the list, but just to make sure. 2. I took your code and added the following, right after $button2 setup: $button2->set_flags(GTK_CAN_DEFAULT); 3. Then I added the default call after the show all for $win: $win->Add($bbox); $win->Show_All(); $button2->grab_default(); Once I did that, I was able to run your code just fine. I don't usually have to add the GTK_CAN_DEFAULT on the buttons in our app - not sure why I had to here. Maybe somebody else has the answer to that one. Also, I usually set ours up with the grab_focus and you get pretty much the same result. The only difference is how the button appears - the grab_default is a more obvious frame. Hope this helps. Madeleine D. At 12:52 PM 7/1/2004 -0700, you wrote: >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 (#4686) next »