set_default_response(..) on an OK button in a Gtk::Dialog does not work



Hi,

I have a simple derived Gtk::Dialog that consists of an Image, a label and an 
entry line. It has a Cancel and an OK button. The entry line allows entry of 
some code.

I would like the OK button activated when the RETURN key is pressed (or of  
course when one uses the mouse to prees OK).

For some reason both "set_default_response (Gtk::RESPONSE_OK);" and a 
combination of "set_flags(CAN_DEFAULT) and "grab default" on the button do 
not work.
(code see  below)

Pressing RETURN does *not* activate OK. 

What is wrong or what am I missing?

Help is much appreciated!

many thanks
Chris



Some_Dialog::Some_Dialog (Gtk::Window* win)
	: Gtk::Dialog ("Some title", *win, true, true)
{
	// 1st hbox
	HBox* sub1_hbox1 = manage (new HBox());
	get_vbox()->add (*sub1_hbox1);
	
		// left image
		Image* sub2_image1 = manage (new Image(Gtk::Stock::DIALOG_AUTHENTICATION, 
Gtk::ICON_SIZE_DIALOG));
		sub1_hbox1->add(*sub2_image1);
		
		VBox* sub2_vbox1 = manage (new VBox());
		sub1_hbox1->add (*sub2_vbox1);

			Label* sub2_label1 = manage (new Label ("Please Enter Code:"));
			sub2_label1->set_alignment (0, -1);
			sub2_vbox1->add(*sub2_label1);

			Entry* sub2_entry1 = manage (new Entry ()); Some_entry = sub2_entry1;
			sub2_entry1->set_width_chars(4);
			sub2_vbox1->add (*sub2_entry1);

	add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	Button* butok = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);

//	butok->set_flags(Gtk::CAN_DEFAULT);	// does not work *************
//	butok->grab_default();

//	set_default_response (Gtk::RESPONSE_OK); // does not work ************
	
	show_all_children();
}

http://www.acurana.de/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]