mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
editablelabel: Stop editing on focus-out
This is the expected behavior for the main use case, treeview-like 'edit one cell at a time'.
This commit is contained in:
parent
77072b3eaa
commit
287d80bd36
@ -30,6 +30,7 @@
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
/**
|
||||
@ -193,12 +194,20 @@ gtk_editable_label_prepare_drag (GtkDragSource *source,
|
||||
gtk_label_get_label (GTK_LABEL (self->label)));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_editable_label_focus_out (GtkEventController *controller,
|
||||
GtkEditableLabel *self)
|
||||
{
|
||||
gtk_editable_label_stop_editing (self, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_editable_label_init (GtkEditableLabel *self)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
GtkDropTarget *target;
|
||||
GtkDragSource *source;
|
||||
GtkEventController *controller;
|
||||
|
||||
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
|
||||
|
||||
@ -228,6 +237,10 @@ gtk_editable_label_init (GtkEditableLabel *self)
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (gtk_editable_label_prepare_drag), self);
|
||||
gtk_widget_add_controller (self->label, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
controller = gtk_event_controller_focus_new ();
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_editable_label_focus_out), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (self));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user