I saw this at TorchLight's bottomhud.layout:
<Window Type="GuiLook/ImageButton" Name="StatsButton" >
......
<Property Name="onClick" Value="guiToggleStats"/>
The property "onClick" Can't be find at the wiki's PushBtton Properties but it can be used without any error on log.
I've written a funtion named "guiToggleStats" , onfortunately it can not work with the button when it's clicked.
I'd wish to know what this "onClick" means and how could it be used.
Thanks for reading.
What's the meaning of PushButton's "onClick" Property ?
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: What's the meaning of PushButton's "onClick" Property ?
Hi,
There is no "onClick" property in the basic CEGUI, which means it's a property added by the Torchlight developers, most likely as a means of attaching functions or scripts to actions (as an aside to this, there also exists an <Event> tag for layout XML that serves a similar purpose, though perhaps not in a way the Torchlight devs needed, so they added the property instead).
So that covers what you probably already knew
The issues as to why your own function does not get called in response to the click is best answered by the Torchlight guys, though I guess that perhaps they have some requirement as to the way that functions are registered within the game. For example, perhaps they have a table that contains all the valid functions or function names, and new or replacement functions would need to be added to this table in some way? Can't know for sure, just a guess 
CE.
There is no "onClick" property in the basic CEGUI, which means it's a property added by the Torchlight developers, most likely as a means of attaching functions or scripts to actions (as an aside to this, there also exists an <Event> tag for layout XML that serves a similar purpose, though perhaps not in a way the Torchlight devs needed, so they added the property instead).
So that covers what you probably already knew
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: What's the meaning of PushButton's "onClick" Property ?
Thanks,deer CE.I also thought they do some changes .But when I found that it can be worked with the code from www.cegui.org ,I can't be sure .
Now I know the truth and wont waste time to try to use it directly ,though I've waste two days.
Thank you very much.

- scriptkid
- Home away from home

- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Re: What's the meaning of PushButton's "onClick" Property ?
Hi,
You can fairly easy work around their setup with the 'pristine' cegui code by using an ordinary click handler. Something like:
And as an implementation:
To me, it looks like the devs register a global event, and then inspect that onClick property from their generic click handler. This way (using the layout) the gui designer(s) don't have to poke any source code
You can fairly easy work around their setup with the 'pristine' cegui code by using an ordinary click handler. Something like:
Code: Select all
// Subscribe handler that toggles the gui stats
WindowManager::getSingleton().getWindow("StatsButton")->
subscribeEvent(PushButton::EventClicked, Event::Subscriber(&MyApp::handleToggleStats, this));
And as an implementation:
Code: Select all
bool MyApp::handleToggleStats(const CEGUI::EventArgs&)
{
// toggle
// event was handled
return true;
}
To me, it looks like the devs register a global event, and then inspect that onClick property from their generic click handler. This way (using the layout) the gui designer(s) don't have to poke any source code
Check out my released snake game using Cegui!
Re: What's the meaning of PushButton's "onClick" Property ?
I've found out a way just as you said.
It can work !
Now I'm trying to use lua script. I thought it's more efficient for debugging.
Forgive my poor english please.
Who is online
Users browsing this forum: No registered users and 4 guests
