From 76239f89c21fccec2278394f85a7c1a3f02c3c90 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Dec 2020 19:08:19 +0100 Subject: [PATCH] LibGUI: Select the edited text by default in StringModelEditingDelegate This way, if you press F2 to edit the name of an item, the name will be selected in the editor that pops up, and you can start typing a new name for it immediately. --- Libraries/LibGUI/ModelEditingDelegate.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/ModelEditingDelegate.h b/Libraries/LibGUI/ModelEditingDelegate.h index 91904ef4bc..2f3c0b2d8f 100644 --- a/Libraries/LibGUI/ModelEditingDelegate.h +++ b/Libraries/LibGUI/ModelEditingDelegate.h @@ -96,7 +96,12 @@ public: return textbox; } virtual Variant value() const override { return static_cast(widget())->text(); } - virtual void set_value(const Variant& value) override { static_cast(widget())->set_text(value.to_string()); } + virtual void set_value(const Variant& value) override + { + auto& textbox = static_cast(*widget()); + textbox.set_text(value.to_string()); + textbox.select_all(); + } }; }