forked from AuroraMiddleware/gtk
gtkpasswordentry: Add a "catchall" click gesture handler
This gesture is set on the whole widget surface, since there's multiple input targets inside an entry (icons, the GtkText itself) it makes sense to consider the full entry an area handling clicks. Ensure these events don't propagate further up, and result in other actions.
This commit is contained in:
parent
58c31b8627
commit
e652054d50
@ -188,9 +188,20 @@ activate_cb (GtkPasswordEntry *entry)
|
|||||||
g_signal_emit (entry, signals[ACTIVATE], 0);
|
g_signal_emit (entry, signals[ACTIVATE], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
catchall_click_press (GtkGestureClick *gesture,
|
||||||
|
int n_press,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_password_entry_init (GtkPasswordEntry *entry)
|
gtk_password_entry_init (GtkPasswordEntry *entry)
|
||||||
{
|
{
|
||||||
|
GtkGesture *catchall;
|
||||||
GtkEntryBuffer *buffer = gtk_password_entry_buffer_new ();
|
GtkEntryBuffer *buffer = gtk_password_entry_buffer_new ();
|
||||||
|
|
||||||
entry->entry = gtk_text_new ();
|
entry->entry = gtk_text_new ();
|
||||||
@ -207,6 +218,12 @@ gtk_password_entry_init (GtkPasswordEntry *entry)
|
|||||||
gtk_widget_set_cursor (entry->icon, gtk_widget_get_cursor (entry->entry));
|
gtk_widget_set_cursor (entry->icon, gtk_widget_get_cursor (entry->entry));
|
||||||
gtk_widget_set_parent (entry->icon, GTK_WIDGET (entry));
|
gtk_widget_set_parent (entry->icon, GTK_WIDGET (entry));
|
||||||
|
|
||||||
|
catchall = gtk_gesture_click_new ();
|
||||||
|
g_signal_connect (catchall, "pressed",
|
||||||
|
G_CALLBACK (catchall_click_press), entry);
|
||||||
|
gtk_widget_add_controller (GTK_WIDGET (entry),
|
||||||
|
GTK_EVENT_CONTROLLER (catchall));
|
||||||
|
|
||||||
gtk_widget_add_css_class (GTK_WIDGET (entry), I_("password"));
|
gtk_widget_add_css_class (GTK_WIDGET (entry), I_("password"));
|
||||||
|
|
||||||
gtk_password_entry_set_extra_menu (entry, NULL);
|
gtk_password_entry_set_extra_menu (entry, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user