mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 09:14:58 +00:00
LibGUI: Implement a basic "any key pressed" edit trigger for TableView
This trigger allows you to initiate cell editing by simply starting to type something into the cell. :^)
This commit is contained in:
parent
f3e4b62be9
commit
5daa19fdab
2 changed files with 13 additions and 2 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <LibGUI/HeaderView.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Model.h>
|
||||
#include <LibGUI/ModelEditingDelegate.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/ScrollBar.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
|
@ -171,7 +172,17 @@ void TableView::keydown_event(KeyEvent& event)
|
|||
activate(cursor_index());
|
||||
return;
|
||||
}
|
||||
return AbstractTableView::keydown_event(event);
|
||||
|
||||
AbstractTableView::keydown_event(event);
|
||||
|
||||
if (event.is_accepted())
|
||||
return;
|
||||
|
||||
if (is_editable() && edit_triggers() & EditTrigger::AnyKeyPressed && !event.text().is_empty()) {
|
||||
begin_editing(cursor_index());
|
||||
if (m_editing_delegate)
|
||||
m_editing_delegate->set_value(event.text());
|
||||
}
|
||||
}
|
||||
|
||||
void TableView::move_cursor(CursorMovement movement, SelectionUpdate selection_update)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue