mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Formspec: change tabs with ctrl(+shift)+tab (#16167)
This change makes it easier to go to the next/previous tab using keyboard controls.
This commit is contained in:
parent
fde6384a09
commit
4454d71d7d
2 changed files with 28 additions and 1 deletions
|
@ -4068,6 +4068,31 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
{
|
||||
if (event.EventType==EET_KEY_INPUT_EVENT) {
|
||||
KeyPress kp(event.KeyInput);
|
||||
// Ctrl (+ Shift) + Tab: Select the (previous or) next tab of a TabControl instance.
|
||||
bool shift = event.KeyInput.Shift;
|
||||
bool ctrl = event.KeyInput.Control;
|
||||
if (event.KeyInput.PressedDown && (event.KeyInput.Key == KEY_TAB && ctrl)) {
|
||||
// Try to find a tab control among our elements
|
||||
for (const FieldSpec &s : m_fields) {
|
||||
if (s.ftype != f_TabHeader)
|
||||
continue;
|
||||
|
||||
IGUIElement *element = getElementFromId(s.fid, true);
|
||||
if (!element || element->getType() != gui::EGUIET_TAB_CONTROL)
|
||||
continue;
|
||||
|
||||
gui::IGUITabControl *tabs = static_cast<gui::IGUITabControl *>(element);
|
||||
s32 num_tabs = tabs->getTabCount();
|
||||
if (num_tabs <= 1)
|
||||
continue;
|
||||
|
||||
s32 active = tabs->getActiveTab();
|
||||
// Shift: Previous tab, No shift: Next tab
|
||||
active = (active + (shift ? -1 : 1) + num_tabs) % num_tabs;
|
||||
tabs->setActiveTab(active);
|
||||
return true; // handled
|
||||
}
|
||||
}
|
||||
if (event.KeyInput.PressedDown && (
|
||||
(kp == EscapeKey) ||
|
||||
((m_client != NULL) && (kp == getKeySetting("keymap_inventory"))))) {
|
||||
|
|
|
@ -831,8 +831,10 @@ bool GUITable::OnEvent(const SEvent &event)
|
|||
return true;
|
||||
}
|
||||
else if (event.KeyInput.Key == KEY_ESCAPE ||
|
||||
event.KeyInput.Key == KEY_SPACE) {
|
||||
event.KeyInput.Key == KEY_SPACE ||
|
||||
(event.KeyInput.Key == KEY_TAB && event.KeyInput.Control)) {
|
||||
// pass to parent
|
||||
return IGUIElement::OnEvent(event);
|
||||
}
|
||||
else if (event.KeyInput.PressedDown && event.KeyInput.Char) {
|
||||
// change selection based on text as it is typed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue