entirely rework event handling take 7
This commit is contained in:
30
handlers.lua
30
handlers.lua
@ -53,11 +53,9 @@ function handlers.handlePasswordInput()
|
|||||||
local password = ""
|
local password = ""
|
||||||
state.enteringPassword = true
|
state.enteringPassword = true
|
||||||
|
|
||||||
-- Register high-priority click handler for password input
|
-- Wait for password submission - handle events directly without the event system
|
||||||
local function passwordClickHandler(eventType, side, x, y)
|
while state.enteringPassword do
|
||||||
if not state.enteringPassword then
|
local _, _, x, y = os.pullEvent("monitor_touch")
|
||||||
return nil -- No longer active, let other handlers process
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check number buttons (1-9)
|
-- Check number buttons (1-9)
|
||||||
if y >= 7 and y <= 15 then
|
if y >= 7 and y <= 15 then
|
||||||
@ -69,7 +67,6 @@ function handlers.handlePasswordInput()
|
|||||||
if num >= 1 and num <= 9 then
|
if num >= 1 and num <= 9 then
|
||||||
password = password .. tostring(num)
|
password = password .. tostring(num)
|
||||||
display.updatePasswordDisplay(password)
|
display.updatePasswordDisplay(password)
|
||||||
return true -- Event consumed
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -80,38 +77,17 @@ function handlers.handlePasswordInput()
|
|||||||
-- Clear button
|
-- Clear button
|
||||||
password = ""
|
password = ""
|
||||||
display.updatePasswordDisplay(password)
|
display.updatePasswordDisplay(password)
|
||||||
return true
|
|
||||||
elseif x >= 13 and x <= 16 then
|
elseif x >= 13 and x <= 16 then
|
||||||
-- Zero button
|
-- Zero button
|
||||||
password = password .. "0"
|
password = password .. "0"
|
||||||
display.updatePasswordDisplay(password)
|
display.updatePasswordDisplay(password)
|
||||||
return true
|
|
||||||
elseif x >= 18 and x <= 21 then
|
elseif x >= 18 and x <= 21 then
|
||||||
-- OK button - submit password
|
-- OK button - submit password
|
||||||
state.enteringPassword = false
|
state.enteringPassword = false
|
||||||
return "submit"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return true -- Consume all clicks during password entry
|
|
||||||
end
|
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
|
-- Send password attempt
|
||||||
utils.sendPasswordAttempt(password)
|
utils.sendPasswordAttempt(password)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user