[Solved] How set PropertyCallback?

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

djphilipe
Quite a regular
Quite a regular
Posts: 48
Joined: Thu Aug 23, 2007 10:15
Location: Slovakia
Contact:

[Solved] How set PropertyCallback?

Postby djphilipe » Mon Apr 04, 2011 13:58

Hi,
I want call loadWindowLayout(const String& filename, const String& name_prefix = "", const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0) with set custom PropertyCallback method.
But I'm confused about function pointers etc...
Can somebody give me an example how can I set custom method?

Thanks
Last edited by djphilipe on Fri Apr 08, 2011 07:15, edited 1 time in total.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: How set PropertyCallback?

Postby Kulik » Mon Apr 04, 2011 14:51

This is a small example of how to make it work:

Code: Select all

bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata)
{
  // some value transformation
  propValue = propValue + "_something";

  return true; // we want the property to be set in the end
}

void main()
{
  WindowManager::getSingleton().loadWindowLayout("File.layout", "", "", &PropertyCallback);
}


If you need to translate values if the property name is text you do:

Code: Select all

bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata)
{
  if (propName == "Text")
  {
    propValue = translateToSK(propValue);
  }

  return true;
}

void main()
{
  WindowManager::getSingleton().loadWindowLayout("File.layout", "", "", &PropertyCallback);
}


To make it tidier, put the PropertyCallback function into a class and make it static.

PS: I have not tried compiling this code, it's off the top of my head. HTH!

djphilipe
Quite a regular
Quite a regular
Posts: 48
Joined: Thu Aug 23, 2007 10:15
Location: Slovakia
Contact:

Re: How set PropertyCallback?

Postby djphilipe » Fri Apr 08, 2011 07:13

I had tried this way even before you wrote me this answer. But I had method PropertyCallback in class (GUIMgr) and it wasn't static method and a compiler fell. I have added keyword "static" before this method and now it's work :)

Thanks for help ;)

PS: I'm looking forward to World Hockey Championship 2011 - Final = Slovakia - Czech republic :P


Return to “Help”

Who is online

Users browsing this forum: No registered users and 12 guests