mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 11:00:29 +00:00
LibGUI: Default-initialize cursor when focusing an AbstractView
If an AbstractView receives focus without a valid cursor index, we now ask it to move its cursor to the home position. This way, the user can actually start moving the cursor after tabbing to a view.
This commit is contained in:
parent
1f789a07b1
commit
de3dc15a6e
Notes:
sideshowbarker
2024-07-19 01:40:47 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/de3dc15a6e8
2 changed files with 9 additions and 0 deletions
|
@ -678,4 +678,12 @@ void AbstractView::draw_item_text(Gfx::Painter& painter, const ModelIndex& index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractView::focusin_event(FocusEvent& event)
|
||||||
|
{
|
||||||
|
ScrollableWidget::focusin_event(event);
|
||||||
|
|
||||||
|
if (model() && !cursor_index().is_valid())
|
||||||
|
move_cursor(CursorMovement::Home, SelectionUpdate::None);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,7 @@ protected:
|
||||||
virtual void drop_event(DropEvent&) override;
|
virtual void drop_event(DropEvent&) override;
|
||||||
virtual void leave_event(Core::Event&) override;
|
virtual void leave_event(Core::Event&) override;
|
||||||
virtual void hide_event(HideEvent&) override;
|
virtual void hide_event(HideEvent&) override;
|
||||||
|
virtual void focusin_event(FocusEvent&) override;
|
||||||
|
|
||||||
virtual void clear_selection();
|
virtual void clear_selection();
|
||||||
virtual void set_selection(const ModelIndex&);
|
virtual void set_selection(const ModelIndex&);
|
||||||
|
|
Loading…
Reference in a new issue