raygui
raygui copied to clipboard
`GuiListView()` always returns 0
Currently with this code:
m_GameObjectSelect = GuiListView(m_GameObjectListBounds,m_GameObjectListString.c_str(),&m_GameObjectScrollIndex,&m_GameObjectActive);
spdlog::info("GameObject select {}",m_GameObjectSelect);
if (m_GameObjectActive != -1)
{
spdlog::info("GameObject active {}",m_GameObjectActive);
}
m_GameObjectSelect is always 0. Shouldnt it be > 0?
GuiListViewEx initializes result value at the top, here https://github.com/raysan5/raygui/blob/54bff64d7dbaefea877b0b2e32323761fc5692f2/src/raygui.h#L3389-L3391 and then it just returns it at the very end, here https://github.com/raysan5/raygui/blob/54bff64d7dbaefea877b0b2e32323761fc5692f2/src/raygui.h#L3532-L3534 but it does not set it anywhere, also there are no early returns from this function, it returns 0 in all cases.
There are a lot of functions that work this way: GuiGroupBox, GuiLine, GuiPanel, GuiScrollPanel, GuiLabel, GuiToggle, GuiToggleGroup, GuiComboBox, GuiProgressBar, GuiStatusBar, GuiDummyRec, GuiListViewEx, GuiColorPanel, GuiColorBarAlpha, GuiColorBarHue, GuiColorPicke, GuiColorPickerHSV, GuiColorPanelHSV, GuiGrid.
This is probably for Forward/Backward Compatibility and for consistency with other functions. All those mentioned functions are usually never expect to fail nor to execute abnormally, and most of them return values by pointer.
For example, GuiListView returns its internal state with int *scrollIndex and int *active parameters.
In your case you should check m_GameObjectActive value to know which value is selected.
Or you may wanna use GuiListViewEx (with Ex) as it also accepts int *focus.
Same issue as https://github.com/raysan5/raygui/issues/439 , https://github.com/raysan5/raygui/issues/402 and https://github.com/raysan5/raygui/issues/371
@terenctbrobots Yeah, return values should be reviewed: https://github.com/raysan5/raygui/issues/402