CTGUI 0.8.3 MenuBar zero signal ID

Started by ksyrx, 23 June 2020, 09:51:18

ksyrx

I use CTGUI and trying create the simple menu bar.

Here is how I connecting the bar:

Code (none) Select

tguiWidget_connectItemSelected(menu, "menuitemclicked", func);


Here is my callback:

Code (none) Select

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

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?

ksyrx

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

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