CTGUI 0.8.3 MenuBar zero signal ID

  • 3 Replies
  • 110 Views
CTGUI 0.8.3 MenuBar zero signal ID
« on: 23 June 2020, 09:51:18 »
I use CTGUI and trying create the simple menu bar.

Here is how I connecting the bar:

tguiWidget_connectItemSelected(menu, "menuitemclicked", func);
 

Here is my callback:

void
func(const sfUint32 *menu, const sfUint32 *text) {
    /* to handle menu and text */
}
 

Signal ID, that returns by tguiWidget_connectItemSelected sets to zero. Is it expected behaviour? Add that tguiWidget_connect returns non-zero and works perfectly.

*

texus

  • *****
  • 1569
    • View Profile
    • Texus's Blog
Re: CTGUI 0.8.3 MenuBar zero signal ID
« Reply #1 on: 23 June 2020, 13:00:31 »
tguiWidget_connectItemSelected returns 0 when it fails.
Could you check what tgui_getLastError() returns (the function is defined in Global.h) after calling tguiWidget_connectItemSelected ?

Also, what TGUI (and CTGUI) version are you using?

Re: CTGUI 0.8.3 MenuBar zero signal ID
« Reply #2 on: 23 June 2020, 15:00:33 »
> ... Could you check what tgui_getLastError() returns ...

Oh, I was looking for getting the last error inattentively...

TGUI: 0.8.7;
CTGUI: 0.8.3;

tgui_getLastError returns: "Signal 'MenuItemClicked' could not provide data for unbound parameters.". I googled it and wandered here: https://forum.tgui.eu/help-requests/signals-unbound-parameter, but not understood how can this be applied to the my problem.

Between this and then, excuse me for post placement about CTGUI here - I haven't found the better section.

*

texus

  • *****
  • 1569
    • View Profile
    • Texus's Blog
Re: CTGUI 0.8.3 MenuBar zero signal ID
« Reply #3 on: 23 June 2020, 18:32:52 »
CTGUI was written to build the TGUI.Net binding, CTGUI wasn't really intended to be used directly. This is why the library lacks documentation and doesn't has a separate forum section.
You can use the library, you just shouldn't expect it to be as user-friendly as TGUI or TGUI.Net.

The problem seems to be that MenuItemClicked isn't of type SignalItem in c++ (and you thus can't use tguiWidget_connectItemSelected), but it has type SignalItemHierarchy.
The SignalItemHierarchy supports functions with 3 sets of parameters:
- No parameters at all (use tguiWidget_connect in CTGUI for this)
- A string parameter with the menu item that was clicked (use tguiWidget_connectString in CTGUI for this)
- A vector of strings with the hierarchy of the clicked menu item (if you don't have submenus then it contains 2 items: the menu and the menu item). This is apparently not available in CTGUI and TGUI.Net.

Although not related to your issue, is there a reason why you are using an older CTGUI version? The last tagged version seems to be 0.8.6, but the CTGUI master branch itself should actually be up-to-date with 0.8.7