inconsistent focus/default behaviour
- From: Marcin Wolinski <wolinski melkor mimuw edu pl>
- To: gtk-list redhat com
- Subject: inconsistent focus/default behaviour
- Date: Mon, 21 Dec 1998 11:18:18 +0100 (CET)
Hello all!
I'm new to this list, so please excuse me if the matter has already
been discussed or is gone in 1.1.9. I'm using Gtk+ 1.1.5 and the
problem is as follows.
Consider a simple window with two buttons each of which can focus and
can default (an actual test program is appended at the end). Let's
call the buttons `Yes' and `No'. In initial state the Yes button has
focus and default. Now press the TAB key once. Focus moves to the No
button. In this situation pressing SPACE activates No (the focused
widget) while pressing ENTER activates Yes (the default widget). I
find this very confusing.
On the other hand if starting in initial state I press the No button
using the mouse and release it without activating, both focus and
default move to the No button. In this state SPACE and ENTER will
activate No.
My question is whether anyone else considers this behaviour erroneous
and thinks it should be changed. (Note that i'm not asking how to
cure this;-)
----
In my opinion whenever a widget that can default gets focus it should
grab the default. This should not depend on whether the focus moved
because of a mouse or keyboard action.
Marcin
#include <gtk/gtk.h>
void button_clicked(GtkWidget *btn, gchar *name) {
g_print("`%s' was clicked\n",name);
}
void main(int argc, char *argv[]) {
GtkWidget *window, *hbox, *yesbtn, *nobtn;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
hbox = gtk_hbutton_box_new();
gtk_container_add(GTK_CONTAINER(window),hbox);
gtk_widget_show(hbox);
yesbtn = gtk_button_new_with_label ("Yes");
gtk_signal_connect(GTK_OBJECT (yesbtn), "clicked",
GTK_SIGNAL_FUNC (button_clicked),
"Yes");
GTK_WIDGET_SET_FLAGS(yesbtn, GTK_CAN_DEFAULT);
gtk_container_add (GTK_CONTAINER (hbox), yesbtn);
gtk_widget_grab_default(yesbtn);
gtk_widget_grab_focus(yesbtn);
gtk_widget_show(yesbtn);
nobtn = gtk_button_new_with_label ("No");
gtk_signal_connect(GTK_OBJECT (nobtn), "clicked",
GTK_SIGNAL_FUNC (button_clicked),
"No");
GTK_WIDGET_SET_FLAGS(nobtn, GTK_CAN_DEFAULT);
gtk_container_add(GTK_CONTAINER (hbox), nobtn);
gtk_widget_show(nobtn);
gtk_widget_show(window);
gtk_main();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]