From 440588987f43f3a3cce6bd05bd031ecf89ef817b Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Wed, 7 Jul 2010 08:48:37 -0500 Subject: Send button-press and button-release events to the entry. Also grab focus at the first key-press. --- src/idoentrymenuitem.c | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/idoentrymenuitem.c b/src/idoentrymenuitem.c index 8e7ab5c..7227201 100644 --- a/src/idoentrymenuitem.c +++ b/src/idoentrymenuitem.c @@ -35,8 +35,8 @@ static gboolean ido_entry_menu_item_key_press (GtkWidget *widget, gpointer data); static gboolean ido_entry_menu_item_button_press (GtkWidget *widget, GdkEventButton *event); -static void ido_entry_menu_item_send_focus_change (GtkWidget *widget, - gboolean in); +static void ido_entry_menu_item_send_focus_change (GtkWidget *widget, + gboolean in); static void entry_realized_cb (GtkWidget *widget, IdoEntryMenuItem *item); static void entry_move_focus_cb (GtkWidget *widget, @@ -112,13 +112,6 @@ ido_entry_menu_item_init (IdoEntryMenuItem *item) gtk_widget_show_all (priv->box); } -static gboolean -ido_entry_menu_item_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - return TRUE; -} - static gboolean is_key_press_valid (IdoEntryMenuItem *item, gint key) @@ -147,9 +140,21 @@ ido_entry_menu_item_key_press (GtkWidget *widget, if (menuitem->priv->selected && is_key_press_valid (menuitem, event->keyval)) { - gtk_widget_event (menuitem->priv->entry, + GtkWidget *entry = menuitem->priv->entry; + + gtk_widget_event (entry, ((GdkEvent *)(void*)(event))); + if (entry->window != NULL) + { + gdk_window_raise (entry->window); + } + + if (!gtk_widget_has_focus (entry)) + { + gtk_widget_grab_focus (entry); + } + /* We've handled the event, but if the key was GDK_Return * we still want to forward the event up to the menu shell * to ensure that the menuitem receives the activate signal. @@ -193,12 +198,10 @@ static gboolean ido_entry_menu_item_button_press (GtkWidget *widget, GdkEventButton *event) { - if (event->button == GDK_BUTTON_PRESS) - { - GtkWidget *entry; - - entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry; + GtkWidget *entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry; + if (event->button == 1) + { if (entry->window != NULL) { gdk_window_raise (entry->window); @@ -209,12 +212,27 @@ ido_entry_menu_item_button_press (GtkWidget *widget, gtk_widget_grab_focus (entry); } + gtk_widget_event (entry, + ((GdkEvent *)(void*)(event))); + return TRUE; } return FALSE; } +static gboolean +ido_entry_menu_item_button_release (GtkWidget *widget, + GdkEventButton *event) +{ + GtkWidget *entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry; + + gtk_widget_event (entry, + ((GdkEvent *)(void*)(event))); + + return TRUE; +} + static void ido_entry_menu_item_select (GtkItem *item) { -- cgit v1.2.3