Page 1 of 1

[Solved] something missing to make events work ?

Posted: Thu Jun 29, 2006 20:36
by khayyam
hi all,

I think something is missing in my code because the events seem not to work properly
(The GUI is correctly displayed)

what I've done :

Code: Select all

CEGUI::LuaScriptModule *scriptmod = new CEGUI::LuaScriptModule();
new CEGUI::System(myRenderer, scriptmod, (CEGUI::utf8*)"cegui.config");

[...]

CEGUI::WindowManager &winMgr = CEGUI::WindowManager::getSingleton();

CEGUI::Window *myRoot = winMgr.loadWindowLayout("../data/schemes/demolayout.xml");
CEGUI::System::getSingleton().setGUISheet(myRoot);


with demolayout.xml

Code: Select all

[...]
<Window Type="TaharezLook/Button" Name="Button1" >
      <Property Name="MouseCursorImage" Value="set:TaharezLook image:MouseArrow" />
      <Property Name="UnifiedAreaRect" Value="{{0.089232,0.000000},{0.207778,0.000000},{0.401089,0.000000},{0.315456,0.000000}}" />
      <Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
      <Event Name="Clicked" Function="luabtn_clicked" />
    </Window>
[...]


and the luabtn_clicked function defined in the lua file called by "cegui.config" (called at creation of CEGUI::System) :

Code: Select all

function luabtn_clicked(e)
  local logger = CEGUI.Logger:getSingleton()
  logger:logEvent( ">>> clic" )
end


Just to see if everything is ok, I put a

Code: Select all

local logger = CEGUI.Logger:getSingleton()
logger:logEvent( ">>> started" )

in the lua file and it's well written in the log file, so this lua file is correctly parsed.

but, the logger:logEvent( ">>> clic" ) inside the luabtn_clicked function is not interpreted when I click the button

What is missing ?
Did I forget something ?

Posted: Sat Jul 01, 2006 11:29
by Dalfy
are you injecting events to cegui ? Did you forward the mouse, keyboard and time event to the library ?

Posted: Sat Jul 01, 2006 13:13
by khayyam
Dalfy wrote:are you injecting events to cegui ?


not at all.
:( http://www.cegui.org.uk/wiki/index.php/ ... ing_Inputs :(

In fact, I'm trying to specify the whole gui only in the xml/lua files, even the events.

that's why I don't have any

Code: Select all

window->subscribeEvent
but

Code: Select all

<Event Name="Clicked" Function="luabtn_clicked" />

Is it what you meant with "injecting inputs" ?

(I think it doesn't)

so, all my events are processed by my renderer, how to inject them into cegui ? (any wiki ? tuto ?)

Posted: Sat Jul 01, 2006 13:31
by MacMan45
Injecting inputs means you get the mouse position etc (clicks, keyboard evens & so on) & every frame pass them to crazy eddie....

Here is an example:

Code: Select all

const OIS::MouseState &ms = mMouse->getMouseState();

CEGUI::System::getSingleton().injectMousePosition(ms.abX,ms.abY);


(in this example i'm using OIS to get my input)

Posted: Sat Jul 01, 2006 15:11
by khayyam
thanks :)

(I was wondering how cegui could get the events, now it's clear)

Posted: Sat Jul 01, 2006 15:15
by MacMan45
Your welcome :)