mirror of
https://github.com/Insality/druid
synced 2025-09-27 10:02:19 +02:00
Add checkboxes example
This commit is contained in:
37
example/examples/general/checkboxes/checkboxes.collection
Normal file
37
example/examples/general/checkboxes/checkboxes.collection
Normal file
@@ -0,0 +1,37 @@
|
||||
name: "checkboxes"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
data: "components {\n"
|
||||
" id: \"checkboxes\"\n"
|
||||
" component: \"/example/examples/general/checkboxes/checkboxes.gui\"\n"
|
||||
" position {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" }\n"
|
||||
" rotation {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" w: 1.0\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
""
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale3 {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
}
|
1454
example/examples/general/checkboxes/checkboxes.gui
Normal file
1454
example/examples/general/checkboxes/checkboxes.gui
Normal file
File diff suppressed because it is too large
Load Diff
45
example/examples/general/checkboxes/checkboxes.gui_script
Normal file
45
example/examples/general/checkboxes/checkboxes.gui_script
Normal file
@@ -0,0 +1,45 @@
|
||||
local druid = require("druid.druid")
|
||||
|
||||
|
||||
local function on_single_checkbox(self, value)
|
||||
print("Single checkbox callback. Value:", value)
|
||||
end
|
||||
|
||||
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
|
||||
local single_checkbox = self.druid:new_checkbox("checkbox/check", on_single_checkbox)
|
||||
|
||||
local radio_group = self.druid:new_radio_group(
|
||||
{"radio1/check", "radio2/check", "radio3/check"},
|
||||
nil,
|
||||
{"radio1/back", "radio2/back", "radio3/back"}) -- last row optional. It's input node (default - click node)
|
||||
radio_group:set_state(2, true)
|
||||
|
||||
local checkbox_group = self.druid:new_checkbox_group(
|
||||
{"checkbox1/check", "checkbox2/check", "checkbox3/check"},
|
||||
nil,
|
||||
{"checkbox1/back", "checkbox2/back", "checkbox3/back"}) -- last row optional. It's input node (default - click node)
|
||||
checkbox_group:set_state({true, false, true}, true)
|
||||
end
|
||||
|
||||
|
||||
function final(self)
|
||||
self.druid:final()
|
||||
end
|
||||
|
||||
|
||||
function update(self, dt)
|
||||
self.druid:update(dt)
|
||||
end
|
||||
|
||||
|
||||
function on_message(self, message_id, message, sender)
|
||||
self.druid:on_message(message_id, message, sender)
|
||||
end
|
||||
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
return self.druid:on_input(action_id, action)
|
||||
end
|
Reference in New Issue
Block a user