What's the meaning of PushButton's "onClick" Property ?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

chenltm
Just popping in
Just popping in
Posts: 8
Joined: Sun Nov 22, 2009 06:50

What's the meaning of PushButton's "onClick" Property ?

Postby chenltm » Sat Jan 30, 2010 06:03

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.

User avatar
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 ?

Postby CrazyEddie » Sat Jan 30, 2010 09:41

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.

chenltm
Just popping in
Just popping in
Posts: 8
Joined: Sun Nov 22, 2009 06:50

Re: What's the meaning of PushButton's "onClick" Property ?

Postby chenltm » Sun Jan 31, 2010 01:42

:hammer: 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. :cry:

Thank you very much. :rofl:

User avatar
scriptkid
Home away from home
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 ?

Postby scriptkid » Sun Jan 31, 2010 13:27

Hi,

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!

chenltm
Just popping in
Just popping in
Posts: 8
Joined: Sun Nov 22, 2009 06:50

Re: What's the meaning of PushButton's "onClick" Property ?

Postby chenltm » Wed Feb 03, 2010 06:14

:D Thanks,scriptkid.

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. :rofl:


Forgive my poor english please. :cry:


Return to “Help”

Who is online

Users browsing this forum: No registered users and 3 guests