1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-04 15:07:34 +00:00

LibGUI: Add AbstractView "edit triggers" to improve editing control

This API allows the embedder of a view to decide which actions upon
the view will begin editing the current item.

To maintain the old behavior, we will begin editing when an item is
either double-clicked, or when the "edit key" (return) is pressed.
This commit is contained in:
Andreas Kling 2020-08-28 20:27:51 +02:00
parent 383ee279ee
commit f3e4b62be9
4 changed files with 27 additions and 12 deletions

View file

@ -248,8 +248,10 @@ void AbstractTableView::doubleclick_event(MouseEvent& event)
if (!model())
return;
if (event.button() == MouseButton::Left) {
if (!selection().is_empty())
activate_or_edit_selected();
if (is_editable() && edit_triggers() & EditTrigger::DoubleClicked)
begin_editing(cursor_index());
else
activate(cursor_index());
}
}