mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 16:25:08 +00:00
LibGUI: Allow basic keyboard navigation in GTableView.
Pressing Enter will now "activate" the selected index, meaning that the model gets a call to activate(GModelIndex).
This commit is contained in:
parent
e1d0a3f226
commit
b5dcad932e
3 changed files with 32 additions and 1 deletions
|
@ -47,13 +47,18 @@ public:
|
|||
virtual ColumnMetadata column_metadata(int) const { return { }; }
|
||||
virtual GVariant data(int row, int column) const = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void activate(const GModelIndex&) { }
|
||||
|
||||
bool is_valid(GModelIndex index) const
|
||||
{
|
||||
return index.row() >= 0 && index.row() < row_count() && index.column() >= 0 && index.column() < column_count();
|
||||
}
|
||||
|
||||
void set_selected_index(const GModelIndex& index) { m_selected_index = index; }
|
||||
void set_selected_index(const GModelIndex& index)
|
||||
{
|
||||
if (is_valid(index))
|
||||
m_selected_index = index;
|
||||
}
|
||||
GModelIndex selected_index() const { return m_selected_index; }
|
||||
|
||||
void register_view(Badge<GTableView>, GTableView&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue