diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-08-07 10:14:50 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-08-07 10:14:50 -0400 |
commit | b213a07a77d7a0ab0d4a092a213d0e31b6611ace (patch) | |
tree | 4ee1d85365365c0e6b0007e1beb082875abc0669 /indra/newview/scripts/lua/test_luafloater_demo.lua | |
parent | da30bd882dd8fbf33215726efd90e53209481f1c (diff) | |
parent | f8c70f4855b4163c82aa7c2e0cc07a5cd81a206f (diff) |
Merge branch 'release/luau-scripting' into viewer-lua-smoother
Diffstat (limited to 'indra/newview/scripts/lua/test_luafloater_demo.lua')
-rw-r--r-- | indra/newview/scripts/lua/test_luafloater_demo.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/test_luafloater_demo.lua b/indra/newview/scripts/lua/test_luafloater_demo.lua new file mode 100644 index 0000000000..3903d01e65 --- /dev/null +++ b/indra/newview/scripts/lua/test_luafloater_demo.lua @@ -0,0 +1,39 @@ +local Floater = require 'Floater' +local leap = require 'leap' +local startup = require 'startup' + +local flt = Floater( + 'luafloater_demo.xml', + {show_time_lbl = {"right_mouse_down", "double_click"}}) + +-- override base-class handleEvents() to report the event data in the floater's display field +function flt:handleEvents(event_data) + self:post({action="add_text", ctrl_name="events_editor", value = event_data}) + -- forward the call to base-class handleEvents() + return Floater.handleEvents(self, event_data) +end + +function flt:commit_disable_ctrl(event_data) + self:post({action="set_enabled", ctrl_name="open_btn", value = (1 - event_data.value)}) +end + +function flt:commit_title_cmb(event_data) + self:post({action="set_title", value=event_data.value}) +end + +function flt:commit_open_btn(event_data) + floater_name = self:request({action="get_value", ctrl_name='openfloater_cmd'}).value + leap.send("LLFloaterReg", {name = floater_name, op = "showInstance"}) +end + +local function getCurrentTime() + local currentTime = os.date("*t") + return string.format("%02d:%02d:%02d", currentTime.hour, currentTime.min, currentTime.sec) +end + +function flt:double_click_show_time_lbl(event_data) + self:post({action="set_value", ctrl_name="time_lbl", value=getCurrentTime()}) +end + +startup.wait('STATE_LOGIN_WAIT') +flt:show() |