[gtk/matthiasc/for-master] editablelabel: Stop editing on focus-out
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] editablelabel: Stop editing on focus-out
- Date: Sat, 18 Jul 2020 14:45:41 +0000 (UTC)
commit 287d80bd36b1d3a717a45c19486e48c45b59b3c6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 18 10:10:38 2020 -0400
editablelabel: Stop editing on focus-out
This is the expected behavior for the main use case,
treeview-like 'edit one cell at a time'.
gtk/gtkeditablelabel.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/gtk/gtkeditablelabel.c b/gtk/gtkeditablelabel.c
index 687de40348..52ca9f3e82 100644
--- a/gtk/gtkeditablelabel.c
+++ b/gtk/gtkeditablelabel.c
@@ -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));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]