mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
checkbox default val and radio type checks for set_value
This commit is contained in:
parent
02e9c09daf
commit
b1446637ad
@ -6,6 +6,7 @@ local element = require("graphics.element")
|
|||||||
---@class checkbox_args
|
---@class checkbox_args
|
||||||
---@field label string checkbox text
|
---@field label string checkbox text
|
||||||
---@field box_fg_bg cpair colors for checkbox
|
---@field box_fg_bg cpair colors for checkbox
|
||||||
|
---@field default? boolean default value
|
||||||
---@field callback? function function to call on press
|
---@field callback? function function to call on press
|
||||||
---@field parent graphics_element
|
---@field parent graphics_element
|
||||||
---@field id? string element id
|
---@field id? string element id
|
||||||
@ -28,7 +29,7 @@ local function checkbox(args)
|
|||||||
-- create new graphics element base object
|
-- create new graphics element base object
|
||||||
local e = element.new(args)
|
local e = element.new(args)
|
||||||
|
|
||||||
e.value = false
|
e.value = args.default == true
|
||||||
|
|
||||||
-- show the button state
|
-- show the button state
|
||||||
local function draw()
|
local function draw()
|
||||||
|
@ -182,7 +182,7 @@ local function radio_2d_button(args)
|
|||||||
-- set the value
|
-- set the value
|
||||||
---@param val integer new value
|
---@param val integer new value
|
||||||
function e.set_value(val)
|
function e.set_value(val)
|
||||||
if val > 0 and val <= #args.options then
|
if type(val) == "number" and val > 0 and val <= #args.options then
|
||||||
e.value = val
|
e.value = val
|
||||||
e.redraw()
|
e.redraw()
|
||||||
end
|
end
|
||||||
|
@ -126,7 +126,7 @@ local function radio_button(args)
|
|||||||
-- set the value
|
-- set the value
|
||||||
---@param val integer new value
|
---@param val integer new value
|
||||||
function e.set_value(val)
|
function e.set_value(val)
|
||||||
if val > 0 and val <= #args.options then
|
if type(val) == "number" and val > 0 and val <= #args.options then
|
||||||
e.value = val
|
e.value = val
|
||||||
e.redraw()
|
e.redraw()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user