瀏覽代碼

Spreadsheet: Add function for moving cursor

This function allows to access cursor movement functionality outside of
SpreadsheetView class.
zawwwu 4 年之前
父節點
當前提交
cf91815654

+ 5 - 0
Userland/Applications/Spreadsheet/SpreadsheetView.cpp

@@ -315,6 +315,11 @@ void SpreadsheetView::show_event(GUI::ShowEvent&)
     }
     }
 }
 }
 
 
+void SpreadsheetView::move_cursor(GUI::AbstractView::CursorMovement direction)
+{
+    m_table_view->move_cursor(direction, GUI::AbstractView::SelectionUpdate::Set);
+}
+
 void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, const Gfx::IntRect& rect, const Gfx::Palette& palette, const GUI::ModelIndex& index)
 void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, const Gfx::IntRect& rect, const Gfx::Palette& palette, const GUI::ModelIndex& index)
 {
 {
     // Draw a border.
     // Draw a border.

+ 2 - 0
Userland/Applications/Spreadsheet/SpreadsheetView.h

@@ -100,6 +100,8 @@ public:
     Function<void(Vector<Position>&&)> on_selection_changed;
     Function<void(Vector<Position>&&)> on_selection_changed;
     Function<void()> on_selection_dropped;
     Function<void()> on_selection_dropped;
 
 
+    void move_cursor(GUI::AbstractView::CursorMovement);
+
 private:
 private:
     virtual void hide_event(GUI::HideEvent&) override;
     virtual void hide_event(GUI::HideEvent&) override;
     virtual void show_event(GUI::ShowEvent&) override;
     virtual void show_event(GUI::ShowEvent&) override;