diff --git a/handlers.lua b/handlers.lua index 7f01118..a56a52a 100644 --- a/handlers.lua +++ b/handlers.lua @@ -40,7 +40,7 @@ end function handlers.handleDefaultClick(eventType, side, x, y) -- Default handler that returns click coordinates -- This has the lowest priority, so other handlers can intercept first - return {x = x, y = y} + return { x = x, y = y } end --------------------------------------------- @@ -110,6 +110,9 @@ function handlers.handlePasswordInput() -- Unregister the password handler events.clearHandlers("monitor_touch") + -- Re-register connection handlers after password entry completes + handlers.setupConnectionHandlers() + -- Send password attempt utils.sendPasswordAttempt(password) @@ -190,12 +193,13 @@ end function handlers.setupConnectionHandlers() -- Clear any existing handlers events.clearHandlers() - -- Register all handlers with their priorities events.registerHandler("monitor_touch", handlers.handleDisconnectButton, events.PRIORITY.DISCONNECT_BUTTON) - events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates + events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates events.registerHandler("stargate_incoming_wormhole", handlers.handleActivation, events.PRIORITY.ACTIVATION) events.registerHandler("stargate_reconstructing_entity", handlers.handleEntityRead, events.PRIORITY.ENTITY_READ) events.registerHandler("stargate_disconnected", handlers.handleDisconnect, events.PRIORITY.DISCONNECT_CHECK) events.registerHandler("stargate_message_received", handlers.handleMessage, events.PRIORITY.MESSAGE) -endreturn handlers +end + +return handlers diff --git a/startup.lua b/startup.lua index f74ab3d..a443564 100644 --- a/startup.lua +++ b/startup.lua @@ -85,7 +85,6 @@ end local function GetClick() mon.setTextScale(1) - handlers.setupConnectionHandlers() local result, eventType, eventData = events.pullEvent("monitor_touch") -- eventData is {eventType, side, x, y} @@ -100,14 +99,12 @@ local function GetClick() end local function GetActivation() - handlers.setupConnectionHandlers() local result = events.pullEvent("stargate_incoming_wormhole") return 1 end local function ParaDisconnect() -- Now handled by event system with priority - handlers.setupConnectionHandlers() while true do local result = events.pullEvent("monitor_touch") if result == "disconnect" then @@ -118,13 +115,11 @@ end local function EntityRead() sleep(0.1) - handlers.setupConnectionHandlers() local result = events.pullEvent("stargate_reconstructing_entity") return 1 end local function DisconnectCheck() - handlers.setupConnectionHandlers() local result = events.pullEvent("stargate_disconnected") return 2 end @@ -135,7 +130,6 @@ local function Paratimeout() end local function GetMessage() - handlers.setupConnectionHandlers() local result = events.pullEvent("stargate_message_received") return 1 end @@ -252,6 +246,9 @@ end local function handleIncomingWormhole() local state = getState() + -- Setup event handlers for this connection + handlers.setupConnectionHandlers() + mon.setBackgroundColor(colors.black) mon.clear() mon.setBackgroundColor(colors.red) @@ -498,6 +495,10 @@ end local function handleOutgoingDial() local state = getState() + + -- Setup event handlers for this connection + handlers.setupConnectionHandlers() + totalstate = true local PDO = 0 PDO = parallel.waitForAny(selectCategory, Paratimeout)