GtkEntry focus out



Hi,

I have a simple GTK (2.2.4) app with a GtkEntry and GtkWidget, the entry
field has a focus out event handler:

gboolean
on_entry1_focus_out_event              (GtkWidget       *widget,
                                        GdkEventFocus   *event,
                                        gpointer         user_data)
{
GtkWidget *dialog = gtk_message_dialog_new
(GTK_WINDOW(lookup_widget(widget,"window1")),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE, "hello");

gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return FALSE;
}

When the message dialog starts, the app abort with an error from the
"blink_cb" function in gtkentry.c.

I can stop the error by adding the following code in the focus out
callback:

    GtkEntry *entry = GTK_ENTRY(widget);
    if (entry->blink_timeout) {
        gtk_timeout_remove (entry->blink_timeout);
        entry->blink_timeout = 0;
    }
                      
    entry->cursor_visible = TRUE;

Interestingly, it works fine if you call a message dialog from either
the focus in or key press events.

Can anyone tell me if this is a bug, or should I not call a dialog from
the focus out event. (The reason I want to call a dialog is, for
example, if only certain stuff can be entered in the GtkEntry, I want to
alert the user).

Thanks,

Bryan




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