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.
This commit is contained in:
Andreas Kling 2020-12-27 19:08:19 +01:00
parent f294bdedcc
commit 76239f89c2
Notes: sideshowbarker 2024-07-19 00:33:21 +09:00

View file

@ -96,7 +96,12 @@ public:
return textbox;
}
virtual Variant value() const override { return static_cast<const TextBox*>(widget())->text(); }
virtual void set_value(const Variant& value) override { static_cast<TextBox*>(widget())->set_text(value.to_string()); }
virtual void set_value(const Variant& value) override
{
auto& textbox = static_cast<TextBox&>(*widget());
textbox.set_text(value.to_string());
textbox.select_all();
}
};
}