-
-
Notifications
You must be signed in to change notification settings - Fork 769
Fixing Issue #1236 Listbox Index #1995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -341,6 +341,7 @@ DearPyGui::fill_configuration_dict(const mvListboxConfig& inConfig, PyObject* ou | |
| return; | ||
| PyDict_SetItemString(outDict, "items", mvPyObject(ToPyList(inConfig.names))); | ||
| PyDict_SetItemString(outDict, "num_items", mvPyObject(ToPyInt(inConfig.itemsHeight))); | ||
| PyDict_SetItemString(outDict, "index", mvPyObject(ToPyBool(inConfig.sendindex))); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the parser, the parameter is named "index_items". Here, its name is "index". Oops. |
||
| } | ||
|
|
||
| void | ||
|
|
@@ -1172,6 +1173,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvListboxConfig& outConfig, mvApp | |
| return; | ||
|
|
||
| if (PyObject* item = PyDict_GetItemString(inDict, "num_items")) outConfig.itemsHeight = ToInt(item); | ||
| if (PyObject* item = PyDict_GetItemString(inDict, "index")) outConfig.sendindex = ToBool(item); | ||
| if (PyObject* item = PyDict_GetItemString(inDict, "items")) | ||
| { | ||
| outConfig.names = ToStringVect(item); | ||
|
|
@@ -4743,9 +4745,16 @@ DearPyGui::draw_listbox(ImDrawList *drawlist, mvAppItem &item, mvListboxConfig & | |
|
|
||
| if (ImGui::ListBox(item.info.internalLabel.c_str(), item.config.enabled ? &config.index : &config.disabledindex, config.charNames.data(), (int)config.names.size(), config.itemsHeight)) | ||
| { | ||
| *config.value = config.names[config.index]; | ||
| config.disabled_value = config.names[config.index]; | ||
| auto value = *config.value; | ||
| if (config.sendindex) { | ||
| *config.value = std::to_string(config.index); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really like the idea of converting the index to a string here. I think |
||
| config.disabled_value = std::to_string(config.index); | ||
| } | ||
| else { | ||
| *config.value = config.names[config.index]; | ||
| config.disabled_value = config.names[config.index]; | ||
| } | ||
|
|
||
| auto value = *config.value; | ||
|
|
||
| if(item.config.alias.empty()) | ||
| mvSubmitCallback([&item, value]() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description says the index would be in user_data, but the code actually puts it to app_data. The description needs to be corrected.