mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibGUI: Add AbstractView::move_cursor() and share some movement logic
A view can now be told to move its cursor in one of multiple directions as specified by the CursorMovement enum. View subclasses can override move_cursor(CursorMovement) to implement their own cursor behavior. By default, AbstractView::move_cursor() is a no-op. This patch improves code sharing between TableView and TreeView. :^)
This commit is contained in:
parent
1b3169f405
commit
0b9d765f6b
Notes:
sideshowbarker
2024-07-19 03:05:35 +09:00
Author: https://github.com/awesomekling
Commit: 0b9d765f6b
7 changed files with 154 additions and 55 deletions
|
@ -383,4 +383,39 @@ void AbstractTableView::set_row_height(int height)
|
|||
update_row_sizes();
|
||||
}
|
||||
|
||||
void AbstractTableView::keydown_event(KeyEvent& event)
|
||||
{
|
||||
if (event.key() == KeyCode::Key_Left) {
|
||||
move_cursor(CursorMovement::Left);
|
||||
event.accept();
|
||||
return;
|
||||
}
|
||||
if (event.key() == KeyCode::Key_Right) {
|
||||
move_cursor(CursorMovement::Right);
|
||||
event.accept();
|
||||
return;
|
||||
}
|
||||
if (event.key() == KeyCode::Key_Up) {
|
||||
move_cursor(CursorMovement::Up);
|
||||
event.accept();
|
||||
return;
|
||||
}
|
||||
if (event.key() == KeyCode::Key_Down) {
|
||||
move_cursor(CursorMovement::Down);
|
||||
event.accept();
|
||||
return;
|
||||
}
|
||||
if (event.key() == KeyCode::Key_Home) {
|
||||
move_cursor(CursorMovement::Home);
|
||||
event.accept();
|
||||
return;
|
||||
}
|
||||
if (event.key() == KeyCode::Key_End) {
|
||||
move_cursor(CursorMovement::End);
|
||||
event.accept();
|
||||
return;
|
||||
}
|
||||
return AbstractView::keydown_event(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue