Page 1 of 1

Fetching the windowName

Posted: Tue Oct 13, 2009 04:49
by saurabh
Hi:

I am writing a multi page application. I load multiple layouts and assign each of them a name. Later when some button event happens, i wish to find that on which layout event occured...

I am doing this but program crashes without logging any error message.

CEGUI::WindowManager *wMgr = CEGUI::WindowManager::getSingletonPtr();
CEGUI::Window *win = wMgr->getWindow((CEGUI::utf8*)"RootWindow");
currentWin = win->getActiveChild()->getName();

Any clue on what is the correct way of achieving this...

Thanks
Saurabh

Re: Fetching the windowName

Posted: Tue Oct 13, 2009 04:51
by saurabh
Crash is happening due to line...
currentWin = win->getActiveChild()->getName();

I am wondering about the role of getActiveChild api. What would it do? Will it return me the layout which i have set visible and attached as a child of rootWindow.

Thanks
Saurabh

Re: Fetching the windowName

Posted: Tue Oct 13, 2009 05:01
by saurabh
I looked into API's documentation. The use getActiveChild() is peculiar.
I thought it'll return the pointer to layout which is active but it is returning a this pointer and also documentation does not say that what will be returned if input is focused on one of the child window and that window is active.

I am presuming that window being active means the window which is visible and has input focus. ...

so suppose we have
X--> Y ---> Z
X--> A ---> B

if Z is the textbox window with input focus then X->getActiveChild() should return pointer to Y .

Thanks
Saurabh

Re: Fetching the windowName

Posted: Tue Oct 13, 2009 11:22
by CrazyEddie
Hi,

The function is possibly poorly named (or at least the docs could be more specific), but this function is behaving in the way intended (and it's always been that way).

CE.

Re: Fetching the windowName

Posted: Wed Oct 14, 2009 00:59
by saurabh
Hi:

I am trying to get the window name...
If suppose i declare a window with this line...

loginSheet = CEGUI::WindowManager::getSingletonPtr()->loadWindowLayout((CEGUI::utf8*)"loginlayout.layout", "LOGIN_WINDOW");
mWindow->addChildWindow(loginSheet);

where mWindow is CEGUI::Window *
Now if i do this...
mWindow->getChildAtIdx(id-1)->getName()

then what should it return. Problem is that i am not able to debug my code because once OGRE renders the sheet then if i press some button once, it just hangs instead of returning to break point and it does not allow me to see what is the output of mWindow->getChildAtIdx(id-1)->getName().

Problems:
1. Ideal output of mWindow->getChildAtIdx(id-1)->getName()
2. How to debug a after OGRE renders the layout. Instead of hitting break point, application just hangs if any event happens after that....

Thanks
Saurabh

Re: Fetching the windowName

Posted: Wed Oct 14, 2009 09:21
by CrazyEddie
Hi,

1) Depending upon the name of the top-level window in the layout file (here I'll assume 'Root' for the sake of simplicity), and assuming the index (id -1) accesses the window added in the line:

Code: Select all

mWindow->addChildWindow(loginSheet);

Then the name would be returned as "LOGIN_WINDOWRoot".

2) Nowhere near enough information given here. What OS? What compiler? Windowed or full-screen? What have you tried, exactly, to narrow down the issue? In this context, what does 'hang' mean?

CE.

Re: Fetching the windowName

Posted: Thu Oct 15, 2009 19:05
by Jamarr
Does your debugger not have a Break All command? You might also want to invest in logging...

Re: Fetching the windowName

Posted: Thu Oct 15, 2009 19:13
by saurabh
Hi,

It works perfectly.
I was not initializing the variable so crash was happening. Sorry for not providing enough details for post mar-tam...

But will take care next time...

Thank
Saurabh