summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua/test_luafloater_demo2.lua
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-04-09 15:21:05 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-04-09 15:21:05 -0400
commit26ce33d8ead68c2dbcc37b2b1e040c072866fe5b (patch)
tree42ff25f1d1db25be3dfc740016ff75d12c847eb1 /indra/newview/scripts/lua/test_luafloater_demo2.lua
parent3114f674aaef019804803bed50972833f5411f93 (diff)
Add Lua Floater class to simplify Lua script showing floaters.
Add test_luafloater_demo2.lua and test_luafloater_gesture_list2.lua examples.
Diffstat (limited to 'indra/newview/scripts/lua/test_luafloater_demo2.lua')
-rw-r--r--indra/newview/scripts/lua/test_luafloater_demo2.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/test_luafloater_demo2.lua b/indra/newview/scripts/lua/test_luafloater_demo2.lua
new file mode 100644
index 0000000000..9e24237d28
--- /dev/null
+++ b/indra/newview/scripts/lua/test_luafloater_demo2.lua
@@ -0,0 +1,39 @@
+local Floater = require 'Floater'
+local leap = require 'leap'
+local startup = require 'startup'
+
+local flt = Floater:new(
+ '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()