summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llluafloater.cpp40
-rw-r--r--indra/newview/scripts/lua/luafloater_demo.xml13
-rw-r--r--indra/newview/scripts/lua/test_luafloater_demo.lua4
-rw-r--r--indra/newview/scripts/lua/test_luafloater_gesture_list.lua3
-rw-r--r--indra/newview/scripts/lua/util.lua10
5 files changed, 48 insertions, 22 deletions
diff --git a/indra/llui/llluafloater.cpp b/indra/llui/llluafloater.cpp
index afc287a864..268075b05d 100644
--- a/indra/llui/llluafloater.cpp
+++ b/indra/llui/llluafloater.cpp
@@ -32,6 +32,7 @@
#include "llcheckboxctrl.h"
#include "llcombobox.h"
#include "llscrolllistctrl.h"
+#include "lltexteditor.h"
const std::string LISTENER_NAME("LLLuaFloater");
@@ -45,7 +46,8 @@ std::set<std::string> EVENT_LIST = {
"right_mouse_down",
"right_mouse_up",
"post_build",
- "floater_close"
+ "floater_close",
+ "keystroke"
};
LLLuaFloater::LLLuaFloater(const LLSD &key) :
@@ -99,6 +101,16 @@ LLLuaFloater::LLLuaFloater(const LLSD &key) :
}
}, requiredParams);
+ mDispatchListener.add("add_text", "", [this](const LLSD &event)
+ {
+ LLTextEditor *editor = getChild<LLTextEditor>(event["ctrl_name"].asString());
+ if (editor)
+ {
+ editor->pasteTextWithLinebreaks(stringize(event["value"]));
+ editor->addLineBreakChar(true);
+ }
+ }, requiredParams);
+
mDispatchListener.add("set_title", "", [this](const LLSD &event)
{
setTitle(event["value"].asString());
@@ -182,6 +194,12 @@ void LLLuaFloater::registerCallback(const std::string &ctrl_name, const std::str
post(event.with("x", x).with("y", y));
};
+ auto post_with_value = [this, data](LLSD value)
+ {
+ LLSD event(data);
+ post(event.with("value", value));
+ };
+
if (event_is(event, "mouse_enter"))
{
ctrl->setMouseEnterCallback(mouse_event_cb);
@@ -211,18 +229,26 @@ void LLLuaFloater::registerCallback(const std::string &ctrl_name, const std::str
LLScrollListCtrl *list = dynamic_cast<LLScrollListCtrl *>(ctrl);
if (list)
{
- list->setDoubleClickCallback(
- [this, data, list]()
- {
- LLSD event(data);
- post(event.with("value", list->getCurrentID()));
- });
+ list->setDoubleClickCallback( [post_with_value, list](){ post_with_value(LLSD(list->getCurrentID())); });
}
else
{
ctrl->setDoubleClickCallback(mouse_event_coords_cb);
}
}
+ else if (event_is(event, "keystroke"))
+ {
+ LLTextEditor* text_editor = dynamic_cast<LLTextEditor*>(ctrl);
+ if (text_editor)
+ {
+ text_editor->setKeystrokeCallback([post_with_value](LLTextEditor *editor) { post_with_value(editor->getValue()); });
+ }
+ LLLineEditor* line_editor = dynamic_cast<LLLineEditor*>(ctrl);
+ if (line_editor)
+ {
+ line_editor->setKeystrokeCallback([post_with_value](LLLineEditor *editor, void* userdata) { post_with_value(editor->getValue()); }, NULL);
+ }
+ }
else
{
LL_WARNS("LuaFloater") << "Can't register callback for unknown event: " << event << " , control: " << ctrl_name << LL_ENDL;
diff --git a/indra/newview/scripts/lua/luafloater_demo.xml b/indra/newview/scripts/lua/luafloater_demo.xml
index 069f229128..b2273d7718 100644
--- a/indra/newview/scripts/lua/luafloater_demo.xml
+++ b/indra/newview/scripts/lua/luafloater_demo.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
legacy_header_height="18"
- height="150"
+ height="300"
layout="topleft"
name="lua_demo"
title="LUA"
@@ -79,4 +79,15 @@
text_color="white"
left_delta="15"
name="time_lbl"/>
+ <text_editor
+ follows="top|left"
+ font="SansSerif"
+ height="140"
+ left="5"
+ enabled="false"
+ name="events_editor"
+ top_pad="15"
+ word_wrap="true"
+ max_length="65536"
+ width="310"/>
</floater>
diff --git a/indra/newview/scripts/lua/test_luafloater_demo.lua b/indra/newview/scripts/lua/test_luafloater_demo.lua
index b81259c060..22ed7d7b3a 100644
--- a/indra/newview/scripts/lua/test_luafloater_demo.lua
+++ b/indra/newview/scripts/lua/test_luafloater_demo.lua
@@ -2,7 +2,6 @@ XML_FILE_PATH = "luafloater_demo.xml"
leap = require 'leap'
coro = require 'coro'
-util = require 'util'
--event pump for sending actions to the floater
COMMAND_PUMP_NAME = ""
@@ -15,7 +14,7 @@ end)
leap.process()
local function _event(event_name)
- if not util.contains(event_list, event_name) then
+ if not table.find(event_list, event_name) then
print_warning("Incorrect event name: " .. event_name)
end
return event_name
@@ -31,6 +30,7 @@ function getCurrentTime()
end
function handleEvents(event_data)
+ post({action="add_text", ctrl_name="events_editor", value = event_data})
if event_data.event == _event("commit") then
if event_data.ctrl_name == "disable_ctrl" then
post({action="set_enabled", ctrl_name="open_btn", value = (1 - event_data.value)})
diff --git a/indra/newview/scripts/lua/test_luafloater_gesture_list.lua b/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
index b46e36b4d9..b1ff129d85 100644
--- a/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
+++ b/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
@@ -2,7 +2,6 @@ XML_FILE_PATH = "luafloater_gesture_list.xml"
leap = require 'leap'
coro = require 'coro'
-util = require 'util'
LLGesture = require 'LLGesture'
--event pump for sending actions to the floater
@@ -16,7 +15,7 @@ end)
leap.process()
local function _event(event_name)
- if not util.contains(event_list, event_name) then
+ if not table.find(event_list, event_name) then
print_warning("Incorrect event name: " .. event_name)
end
return event_name
diff --git a/indra/newview/scripts/lua/util.lua b/indra/newview/scripts/lua/util.lua
index 5d6042dfe5..e3af633ea7 100644
--- a/indra/newview/scripts/lua/util.lua
+++ b/indra/newview/scripts/lua/util.lua
@@ -36,14 +36,4 @@ function util.equal(t1, t2)
return util.empty(temp)
end
--- check if array-like table contains certain value
-function util.contains(t, v)
- for _, value in ipairs(t) do
- if value == v then
- return true
- end
- end
- return false
-end
-
return util