mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
fixed push button touch redraw
This commit is contained in:
parent
2918608326
commit
f5c703a8b3
@ -37,9 +37,14 @@ local function push_button(args)
|
|||||||
local h_pad = math.floor((e.frame.w - text_width) / 2) + 1
|
local h_pad = math.floor((e.frame.w - text_width) / 2) + 1
|
||||||
local v_pad = math.floor(e.frame.h / 2) + 1
|
local v_pad = math.floor(e.frame.h / 2) + 1
|
||||||
|
|
||||||
|
-- draw the button
|
||||||
|
local function draw()
|
||||||
|
e.window.clear()
|
||||||
|
|
||||||
-- write the button text
|
-- write the button text
|
||||||
e.window.setCursorPos(h_pad, v_pad)
|
e.window.setCursorPos(h_pad, v_pad)
|
||||||
e.window.write(args.text)
|
e.window.write(args.text)
|
||||||
|
end
|
||||||
|
|
||||||
-- handle touch
|
-- handle touch
|
||||||
---@param event monitor_touch monitor touch event
|
---@param event monitor_touch monitor touch event
|
||||||
@ -49,13 +54,13 @@ local function push_button(args)
|
|||||||
-- show as pressed
|
-- show as pressed
|
||||||
e.window.setTextColor(args.active_fg_bg.fgd)
|
e.window.setTextColor(args.active_fg_bg.fgd)
|
||||||
e.window.setBackgroundColor(args.active_fg_bg.bkg)
|
e.window.setBackgroundColor(args.active_fg_bg.bkg)
|
||||||
e.window.redraw()
|
draw()
|
||||||
|
|
||||||
-- show as unpressed in 0.5 seconds
|
-- show as unpressed in 0.25 seconds
|
||||||
tcd.dispatch(0.5, function ()
|
tcd.dispatch(0.25, function ()
|
||||||
e.window.setTextColor(e.fg_bg.fgd)
|
e.window.setTextColor(e.fg_bg.fgd)
|
||||||
e.window.setBackgroundColor(e.fg_bg.bkg)
|
e.window.setBackgroundColor(e.fg_bg.bkg)
|
||||||
e.window.redraw()
|
draw()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,6 +68,9 @@ local function push_button(args)
|
|||||||
args.callback()
|
args.callback()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- initial draw
|
||||||
|
draw()
|
||||||
|
|
||||||
return e.get()
|
return e.get()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user