entirely rework event handling take 7

This commit is contained in:
2025-12-29 01:40:06 -05:00
parent 9a11a20e5a
commit c4fb273f55

View File

@ -53,11 +53,9 @@ function handlers.handlePasswordInput()
local password = ""
state.enteringPassword = true
-- Register high-priority click handler for password input
local function passwordClickHandler(eventType, side, x, y)
if not state.enteringPassword then
return nil -- No longer active, let other handlers process
end
-- Wait for password submission - handle events directly without the event system
while state.enteringPassword do
local _, _, x, y = os.pullEvent("monitor_touch")
-- Check number buttons (1-9)
if y >= 7 and y <= 15 then
@ -69,7 +67,6 @@ function handlers.handlePasswordInput()
if num >= 1 and num <= 9 then
password = password .. tostring(num)
display.updatePasswordDisplay(password)
return true -- Event consumed
end
end
end
@ -80,38 +77,17 @@ function handlers.handlePasswordInput()
-- Clear button
password = ""
display.updatePasswordDisplay(password)
return true
elseif x >= 13 and x <= 16 then
-- Zero button
password = password .. "0"
display.updatePasswordDisplay(password)
return true
elseif x >= 18 and x <= 21 then
-- OK button - submit password
state.enteringPassword = false
return "submit"
end
end
return true -- Consume all clicks during password entry
end
-- Clear all monitor_touch handlers and register only password handler
events.clearHandlers("monitor_touch")
events.registerHandler("monitor_touch", passwordClickHandler, events.PRIORITY.PASSWORD_INPUT)
-- Wait for password submission
while state.enteringPassword do
local result = events.pullEvent("monitor_touch")
if result == "submit" then
break
end
-- Don't process the result here - the handler already did it
end
-- Re-register connection handlers after password entry completes
handlers.setupConnectionHandlers()
-- Send password attempt
utils.sendPasswordAttempt(password)