Skip to content

fix: boundKeyPressCombos [fix: #1000, #1251 , #1231 , #738]#1253

Merged
mehah merged 3 commits intoopentibiabr:mainfrom
kokekanon:fixAddons
Jul 27, 2025
Merged

fix: boundKeyPressCombos [fix: #1000, #1251 , #1231 , #738]#1253
mehah merged 3 commits intoopentibiabr:mainfrom
kokekanon:fixAddons

Conversation

@kokekanon
Copy link
Copy Markdown
Contributor

@kokekanon kokekanon commented Jul 27, 2025

this code was made more than 4 years ago (Jul 24, 2021). f247211

Prevent executing hotkeys when windows are opened
Hotkeys assigned to letters (without ctrl or alt) will be blocked when
wasd mode is off.

Also, can't execute hotkeys when there is any window opened for the
exact same reason: prevent executing hotkeys when typing.

but it is currently causing problems: #1000, #1251 , #1231 , #738

modules.game_hotkeys.createHotkeyBlock("identifier")

Creates a hotkey block

local block = modules.game_hotkeys.createHotkeyBlock("spell_assign_window")

Returns: A block object with:

  • release() - Releases the hotkey block
  • getId() - Returns ID "spell_assign_window_gameActionbar" ["argument + source module"] trasability

modules.game_hotkeys.areHotkeysDisabled()

Checks if any hotkey blocks are currently active.

modules.game_hotkeys.areHotkeysDisabled()

modules.game_hotkeys.printHotkeyBlockingInfo()

returns information about who blocked it and what module it was

> modules.game_hotkeys.printHotkeyBlockingInfo()
=== Hotkey Blocking Info ===
Total blocks: 1
Active sources:
  1. spell_assign_window_gameactionbar
===========================

Automatic vs Manual Management

Automatic Cleanup

When you assign the block to a window's hotkeyBlock property, cleanup happens automatically on destroy():
example

function openDialog()
    myWindow = g_ui.loadUI('dialog', parent)
    myWindow.hotkeyBlock = modules.game_hotkeys.createHotkeyBlock("my_dialog") -- Hotkeys disable
    myWindow:show()
end

function closeDialog()
    myWindow:destroy()  -- Hotkeys automatically enabled
    myWindow = nil
end

Manual Management

When you use hide() instead of destroy(), you must manually release:

function openDialog()
    myWindow = g_ui.loadUI('dialog', parent)
    dialogHotkeyBlock = modules.game_hotkeys.createHotkeyBlock("my_dialog")
    myWindow:show()
end

function hideDialog()
    myWindow:hide()  -- ⚠️ Window still exists, hotkeys still blocked
    ...
    -- ❌ WRONG: Hotkeys remain blocked forever
    ...
    -- ✅ CORRECT: Must manually release
    if dialogHotkeyBlock then
        dialogHotkeyBlock.release()
        dialogHotkeyBlock = nil
    end
end

Old Code

the author of the code does not handle destroy()

function openDialog()
    modules.game_hotkeys.enableHotkeys(false)  -- Old way
end

function closeDialog()
    modules.game_hotkeys.enableHotkeys(true)   -- Old way  
end

use case

game_shop (free hotkeys in wasd) vs game_actionbar (block hotkeys in wasd)
when closing actiobar windows, hotkeys are released

2025-07-26.23-59-26.mp4

@sonarqubecloud
Copy link
Copy Markdown

@mehah mehah merged commit cfc054d into opentibiabr:main Jul 27, 2025
4 checks passed
@mehah mehah deleted the fixAddons branch July 27, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants