瀏覽代碼

LibGUI: Cycle through TabWidget tabs with Ctrl+Tab / Ctrl+Shift+Tab

Fixes #2022.
Andreas Kling 5 年之前
父節點
當前提交
f2cdef5c47
共有 2 個文件被更改,包括 14 次插入0 次删除
  1. 13 0
      Libraries/LibGUI/TabWidget.cpp
  2. 1 0
      Libraries/LibGUI/TabWidget.h

+ 13 - 0
Libraries/LibGUI/TabWidget.cpp

@@ -332,4 +332,17 @@ void TabWidget::activate_previous_tab()
     set_active_widget(m_tabs.at(index).widget);
 }
 
+void TabWidget::keydown_event(KeyEvent & event)
+{
+    if (event.ctrl() && event.key() == Key_Tab) {
+        if (event.shift())
+            activate_previous_tab();
+        else
+            activate_next_tab();
+        event.accept();
+        return;
+    }
+    Widget::keydown_event(event);
+}
+
 }

+ 1 - 0
Libraries/LibGUI/TabWidget.h

@@ -90,6 +90,7 @@ protected:
     virtual void mousedown_event(MouseEvent&) override;
     virtual void mousemove_event(MouseEvent&) override;
     virtual void leave_event(Core::Event&) override;
+    virtual void keydown_event(KeyEvent&) override;
 
 private:
     Gfx::Rect child_rect_for_size(const Gfx::Size&) const;