From 1383a697ae643021c3e80f376f3d75160f3e688c Mon Sep 17 00:00:00 2001 From: Moonlit Productions Date: Mon, 29 Dec 2025 01:36:18 -0500 Subject: [PATCH] entirely rework event handling take 6 --- handlers.lua | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/handlers.lua b/handlers.lua index 25264e4..8be6b2f 100644 --- a/handlers.lua +++ b/handlers.lua @@ -53,6 +53,10 @@ function handlers.handlePasswordInput() local password = "" 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 local function passwordClickHandler(eventType, side, x, y) if not state.enteringPassword then @@ -96,10 +100,9 @@ function handlers.handlePasswordInput() return true -- Consume all clicks during password entry end - -- Register the password handler with highest priority - -- First, clear all monitor_touch handlers to avoid duplicates - events.clearHandlers("monitor_touch") - events.registerHandler("monitor_touch", passwordClickHandler, events.PRIORITY.PASSWORD_INPUT) + -- Clear monitor_touch handlers and register only password handler + eventHandlers["monitor_touch"] = { passwordClickHandler } + handlerPriorities["monitor_touch"] = { events.PRIORITY.PASSWORD_INPUT } -- Wait for password submission while state.enteringPassword do @@ -107,15 +110,17 @@ function handlers.handlePasswordInput() if result == "submit" then break end + -- Don't process the result here - the handler already did it end - -- Unregister the password handler - events.clearHandlers("monitor_touch") + -- Restore old handlers + eventHandlers["monitor_touch"] = oldHandlers + handlerPriorities["monitor_touch"] = oldPriorities - -- Re-register connection handlers after password entry completes - handlers.setupConnectionHandlers() - - -- Send password attempt + -- If no handlers to restore, re-register connection handlers + if #oldHandlers == 0 then + handlers.setupConnectionHandlers() + end -- Send password attempt utils.sendPasswordAttempt(password) return password