Page 1 of 1

Starting with Lua (episode 2)

Posted: Wed Jun 10, 2009 17:51
by xabila
i'm trying to add the Rollup on my window loaded by lua.

Code: Select all

local root = winMgr:loadWindowLayout("ppt.layout")

root:setMousePassThroughEnabled( true)
CEGUI.System:getSingleton():getGUISheet():addChildWindow(root)
   
function luaRollUp(e)
  local we = CEGUI.toWindowEventArgs(e)
  we.window:toggleRollup()
  if we.window:isRollup() then
  we.window:setText("ON ROLLUP OFF");
else
  we.window:setText("ON ROLLUP ON");
end
end
root:subscribeEvent("RollUpToggled","luaRollUp")
root:subscribeEvent("RollupToggled","luaRollUp")




So First it never entered on the function, maybe it's not RollUpToogled ? in c++ it's EventRollupToogled

So i tried to associate it to the CloseClicked

Code: Select all

root:subscribeEvent("CloseClicked","luaRollUp")


But now it crashed, because i guess i should cast it to FrameWindow but i don't know how to do that in lua :(

Re: Starting with Lua (episode 2)

Posted: Sun Jun 14, 2009 10:28
by CrazyEddie
The rollup event name is "RollupToggled".

To cast window types in Lua, use the casting helper, such as you did for the EventArgs. So, for a frame window, you might do:

Code: Select all

local fw = CEGUI.toFrameWindow( we.window )


HTH

CE.

Re: Starting with Lua (episode 2)

Posted: Tue Jun 16, 2009 19:33
by xabila
Ok thanks a lot