diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-01 19:13:51 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-01 19:13:51 (GMT) |
| commit | 6d991c10d7800859a39e447ec7f95b861d5fb69f (patch) | |
| tree | 8244e80d38182a527248235340a634db923e88cd /src/cat/LuaButton.cpp | |
| parent | 9bc06a2fc4d7d4ce82da7323a567402d7688d3d3 (diff) | |
| download | powder-6d991c10d7800859a39e447ec7f95b861d5fb69f.zip powder-6d991c10d7800859a39e447ec7f95b861d5fb69f.tar.gz | |
Logging for UI component events, tr
Diffstat (limited to 'src/cat/LuaButton.cpp')
| -rw-r--r-- | src/cat/LuaButton.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/cat/LuaButton.cpp b/src/cat/LuaButton.cpp index 9ba5bd1..18001fd 100644 --- a/src/cat/LuaButton.cpp +++ b/src/cat/LuaButton.cpp @@ -7,6 +7,7 @@ extern "C" #include <iostream> #include "LuaButton.h" +#include "LuaScriptInterface.h" #include "interface/Button.h" const char LuaButton::className[] = "Button"; @@ -29,7 +30,12 @@ LuaButton::LuaButton(lua_State * l) : int sizeX = luaL_optinteger(l, 3, 10); int sizeY = luaL_optinteger(l, 4, 10); std::string text = luaL_optstring(l, 5, ""); - std::string toolTip = luaL_optstring(l, 6, "");; + std::string toolTip = luaL_optstring(l, 6, ""); + + lua_pushstring(l, "Luacon_ci"); + lua_gettable(l, LUA_REGISTRYINDEX); + ci = (LuaScriptInterface*)lua_touserdata(l, -1); + lua_pop(l, 1); button = new ui::Button(ui::Point(posX, posY), ui::Point(sizeX, sizeY), text, toolTip); class ClickAction : public ui::ButtonAction @@ -116,12 +122,11 @@ void LuaButton::triggerAction() { if(actionFunction) { - std::cout << actionFunction << std::endl; lua_rawgeti(l, LUA_REGISTRYINDEX, actionFunction); - lua_pushinteger(l, 1); + lua_rawgeti(l, LUA_REGISTRYINDEX, UserData); if (lua_pcall(l, 1, 0, 0)) { - //Log error somewhere + ci->Log(CommandInterface::LogError, lua_tostring(l, -1)); } } } |
