Adanos020 / egui_dock

Docking support for egui – an immediate-mode GUI library for Rust
MIT License
458 stars 75 forks source link

Keyboard focus works with Shift+Tab but not with just the Tab key #207

Closed white-axe closed 10 months ago

white-axe commented 11 months ago

Describe the bug Egui allows users to focus widgets using the keyboard, i.e. selecting focusable widgets like buttons, using the Tab key to navigate in forward order or Shift+Tab to navigate in reverse order. However, widgets in an egui_dock tab will only be navigable in this way if the user uses Shift+Tab. Pressing the Tab key does not work.

To Reproduce Replace the ui.label(format!("Content of {tab}")); here in the "simple" example with let _ = ui.button(format!("Content of {tab}")); and then run it. https://github.com/Adanos020/egui_dock/blob/c3604425943d9c5f922a8b9aba8e5a5b89e785e9/examples/simple.rs#L26

When holding down Shift+Tab, the focus cycles between the buttons inside the tabs.

When holding down the Tab key alone, nothing happens.

Expected behavior When holding down the Tab key, the focus should cycle between the buttons in the reverse of the order that Shift+Tab cycles the buttons in.

Screenshots This is what's supposed to happen when holding Tab, but in reverse order: screenshot

white-axe commented 10 months ago

It turns out this bug is being caused by this context menu. Disabling it by using .tab_context_menus(false) when creating the DockArea fixes it. https://github.com/Adanos020/egui_dock/blob/fae7fbc9483ed62fd982c88201a7f8f1b4563559/src/widgets/dock_area/show/leaf.rs#L312-L345 I'll see if I can figure out how to fix the bug without disabling the context menu.