Re: GtkEditable::activate bug or feature?
- From: Guy Harris <gharris flashcom net>
- To: Havoc Pennington <hp redhat com>
- Cc: gtk-devel-list redhat com, gtk-list <gtk-list redhat com>
- Subject: Re: GtkEditable::activate bug or feature?
- Date: Wed, 28 Jun 2000 00:54:58 -0700
On Tue, Jun 27, 2000 at 09:33:14AM -0400, Havoc Pennington wrote:
> It's not a bug, in general objects should never change their behavior
> based on whether there are signal handlers or not (and indeed the
> signal system provides no way of finding out that information AFAIK).
>
> All you have to do is connect activate to gtk_window_activate_default,
> like this:
>
> gtk_signal_connect_object(GTK_OBJECT(editable), "activate",
> GTK_SIGNAL_FUNC(gtk_window_activate_default),
> GTK_OBJECT(dialog));
>
> 90% of the time you have a single entry in a dialog, that's the right
> thing to do.
To which message is this a reply, if any?
I vaguely remember a message to which this might have been a reply, but
I may be misremembering - I don't see any message with
"GtkEditable::activate bug or feature?" in the subject (and your message
doesn't have a "Re:" in the subject).
I infer from the message that somebody *might* have been suggesting that
a GtkEditable that didn't have anything connected to "activate" should
change its behavior in some fashion, e.g. arranging that it call
"gtk_window_activate_default()" so that <Enter> would activate the
default button regardless of whether you're in e.g. a GtkEntry or not.
It *is* a bit of a pain to have to do this manually when creating a
dialog box....
(It's also a bit of a pain to have to catch "key_press_event" in a
dialog window:
void
dlg_set_cancel(GtkWidget *widget, GtkWidget *cancel_button)
{
gtk_signal_connect(GTK_OBJECT(widget), "key_press_event",
GTK_SIGNAL_FUNC(dlg_key_press), cancel_button);
}
and have the handler do
static gint
dlg_key_press (GtkWidget *widget, GdkEventKey *event, gpointer cancel_button)
{
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (event->keyval == GDK_Escape) {
gtk_widget_activate(GTK_WIDGET(cancel_button));
return TRUE;
}
return FALSE;
}
where "cancel_button" is a "Cancel" button in the dialog box, so that
dialog boxes can be dismissed by hitting <ESC>.)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]