entirely rework event handling take 6

This commit is contained in:
2025-12-29 01:36:18 -05:00
parent b37fff262d
commit 1383a697ae

View File

@ -53,6 +53,10 @@ function handlers.handlePasswordInput()
local password = "" local password = ""
state.enteringPassword = true state.enteringPassword = true
-- Store old handlers to restore later
local oldHandlers = eventHandlers["monitor_touch"] or {}
local oldPriorities = handlerPriorities["monitor_touch"] or {}
-- Register high-priority click handler for password input -- Register high-priority click handler for password input
local function passwordClickHandler(eventType, side, x, y) local function passwordClickHandler(eventType, side, x, y)
if not state.enteringPassword then if not state.enteringPassword then
@ -96,10 +100,9 @@ function handlers.handlePasswordInput()
return true -- Consume all clicks during password entry return true -- Consume all clicks during password entry
end end
-- Register the password handler with highest priority -- Clear monitor_touch handlers and register only password handler
-- First, clear all monitor_touch handlers to avoid duplicates eventHandlers["monitor_touch"] = { passwordClickHandler }
events.clearHandlers("monitor_touch") handlerPriorities["monitor_touch"] = { events.PRIORITY.PASSWORD_INPUT }
events.registerHandler("monitor_touch", passwordClickHandler, events.PRIORITY.PASSWORD_INPUT)
-- Wait for password submission -- Wait for password submission
while state.enteringPassword do while state.enteringPassword do
@ -107,15 +110,17 @@ function handlers.handlePasswordInput()
if result == "submit" then if result == "submit" then
break break
end end
-- Don't process the result here - the handler already did it
end end
-- Unregister the password handler -- Restore old handlers
events.clearHandlers("monitor_touch") eventHandlers["monitor_touch"] = oldHandlers
handlerPriorities["monitor_touch"] = oldPriorities
-- Re-register connection handlers after password entry completes -- If no handlers to restore, re-register connection handlers
handlers.setupConnectionHandlers() if #oldHandlers == 0 then
handlers.setupConnectionHandlers()
-- Send password attempt end -- Send password attempt
utils.sendPasswordAttempt(password) utils.sendPasswordAttempt(password)
return password return password