Re: Doesn't focus to Gtk::Dialog buttons



Solved, thanks, but...

2011/10/13 Yann LEYDIER <yann leydier info>:
> My bad, there is no set_activates_default in ComboBoxText.
>
> You can connect the combobox' signal_changed() to the dialog's method
> "activate_default" :
>
> mycombo.signal_changed().connect(sigc::mem_fun(mydialog,
> &Gtk::Dialog::activate_default));

I use this signal to know when the current combo value changes...

> If that is not what you want, call grab_focus() on the button you want (you
> might need to call it after the dialog is pop up, through a mysterious
> signal such as map ou realize...).

GRAB_FOCUS() .... Bingo !!!

	set_response_sensitive (Gtk::RESPONSE_OK, bt_OK);
	set_response_sensitive (Gtk::RESPONSE_APPLY, bt_APPLY);
	
	if (bt_APPLY)
		ref_bt_APPLY->grab_focus();
	else
		ref_bt_OK->grab_focus();

	show_all_children();

	gint result = run();

Moreover, I wrote a little error in my code..

>> ref_bt_OK = add_button (Gtk::Stock::GO_FORWARD, Gtk::RESPONSE_APPLY);
>> ref_bt_APPLY = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);

should be,

	ref_bt_APPLY = add_button (Gtk::Stock::GO_FORWARD, Gtk::RESPONSE_APPLY);
	ref_bt_OK = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);

Thanks Yann,

Glus

> yann
>
> On 13/10/11 19:17, Glus Xof wrote:
>>
>> 2011/10/13 Yann LEYDIER<yann leydier info>:
>>>
>>> Since this widget can input text, it should have a
>>> "set_activates_default".
>>> This will tell Gtk that if the user presses enter in this widget, it will
>>> send the default response to the dialog it belongs.
>>>
>>> yann
>>
>> You should mean set_receives_default() instead, shouldn't it?
>>
>> But nothing changes...
>>
>> I test with joining this method to the Gtk::Dialog derived object
>> without success... Then with,
>>
>> Gtk::Button * ref_bt_OK;
>> Gtk::Button * ref_bt_APPLY;
>>
>> ref_bt_OK = add_button (Gtk::Stock::GO_FORWARD, Gtk::RESPONSE_APPLY);
>> ref_bt_APPLY = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
>>
>> if (bt_APPLY)
>>     ref_bt_APPLY->set_receives_default();
>> else
>>     ref_bt_OK->set_receives_default();
>>
>> But doesn't run either... Ggggrrr....
>>
>>
>>> On 13/10/11 18:03, Glus Xof wrote:
>>>>
>>>> Hi,
>>>>
>>>> After a few days of my last message, I don't reach to solve it. It
>>>> shouldn't be any bug, because in other cases
>>>> Gtk::Dialog::set_response_sensitive() works perfectly... I just don't
>>>> understand what happens here...
>>>>
>>>> The method first fill the three comboboxes with the suitable values
>>>> and then configures the default focus. I don't understand why the
>>>> focus is placed on the first combobox of my dialog...
>>>>
>>>> I test with putting Gtk::Dialog::show_all_children() just before "gint
>>>> result = run()"... but nothing changes, or seems so...
>>>>
>>>> What could I do to see what happens ???
>>>>
>>>> Glus
>>>>
>>>>> In a method of  Gtk::Dialog derived object, I have,
>>>>>
>>>>> // bool bt_OK, bt_APPLY....
>>>>>
>>>>>        set_response_sensitive (Gtk::RESPONSE_OK, bt_OK);
>>>>>        set_response_sensitive (Gtk::RESPONSE_APPLY, bt_APPLY);
>>>>>
>>>>>        if (bt_APPLY)
>>>>>                set_default_response (Gtk::RESPONSE_APPLY);
>>>>>        else
>>>>>                set_default_response (Gtk::RESPONSE_OK);
>>>>>
>>>>>        gint result = run();
>>>>>
>>>>> But at the run time, focus applies to an other child widget (the very
>>>>> first Gtk::ComboBoxText...)
>>>>>
>>>>> (I use the master, the very newest version of GTKmm 3.2.x...)
>>>>>
>>>>> Is it possible to guess what's happen ?
>>>>>
>>>>> Glus
>>>>>
>>>> _______________________________________________
>>>> gtkmm-list mailing list
>>>> gtkmm-list gnome org
>>>> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>>
>>> _______________________________________________
>>> gtkmm-list mailing list
>>> gtkmm-list gnome org
>>> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>>
>
>


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