mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#226 bugfixes and pocket mouse events
This commit is contained in:
@ -105,7 +105,7 @@ local function multi_button(args)
|
||||
---@param event mouse_interaction mouse event
|
||||
function e.handle_mouse(event)
|
||||
-- if enabled and the button row was pressed...
|
||||
if e.enabled and core.events.was_clicked(event.type) and (event.initial.y == 1) and (event.current.y == 1) then
|
||||
if e.enabled and core.events.was_clicked(event.type) then
|
||||
-- a button may have been pressed, which one was it?
|
||||
local button_ini = which_button(event.initial.x)
|
||||
local button_cur = which_button(event.current.x)
|
||||
|
@ -26,6 +26,8 @@ local CLICK_TYPE = core.events.CLICK_TYPE
|
||||
local function push_button(args)
|
||||
assert(type(args.text) == "string", "graphics.elements.controls.push_button: text is a required field")
|
||||
assert(type(args.callback) == "function", "graphics.elements.controls.push_button: callback is a required field")
|
||||
assert(type(args.min_width) == "nil" or (type(args.min_width) == "number" and args.min_width > 0),
|
||||
"graphics.elements.controls.push_button: min_width must be nil or a number > 0")
|
||||
|
||||
local text_width = string.len(args.text)
|
||||
|
||||
|
@ -23,13 +23,15 @@ local function switch_button(args)
|
||||
assert(type(args.text) == "string", "graphics.elements.controls.switch_button: text is a required field")
|
||||
assert(type(args.callback) == "function", "graphics.elements.controls.switch_button: callback is a required field")
|
||||
assert(type(args.active_fg_bg) == "table", "graphics.elements.controls.switch_button: active_fg_bg is a required field")
|
||||
assert(type(args.min_width) == "nil" or (type(args.min_width) == "number" and args.min_width > 0),
|
||||
"graphics.elements.controls.switch_button: min_width must be nil or a number > 0")
|
||||
|
||||
-- single line
|
||||
args.height = 1
|
||||
|
||||
-- determine widths
|
||||
local text_width = string.len(args.text)
|
||||
args.width = math.max(text_width + 2, args.min_width)
|
||||
|
||||
-- single line height, calculate width
|
||||
args.height = 1
|
||||
args.min_width = args.min_width or 0
|
||||
args.width = math.max(text_width, args.min_width)
|
||||
|
||||
-- create new graphics element base object
|
||||
local e = element.new(args)
|
||||
|
Reference in New Issue
Block a user