mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 20:24:16 +01:00
Avoid crashing when clicking Choose with no item selected
Also "Disabled" (darkened) the choose button if no item is selected.
This commit is contained in:
parent
8072f91f51
commit
eafe992f4a
1 changed files with 13 additions and 5 deletions
|
|
@ -186,15 +186,23 @@ namespace Dalamud.Interface
|
||||||
|
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
|
|
||||||
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) {
|
// Darken choose button if it shouldn't be clickable
|
||||||
OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]);
|
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 ? 0.25f : 1);
|
||||||
|
|
||||||
if (this.closeOnChoose) {
|
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) {
|
||||||
this.selectedItemTex?.Dispose();
|
try {
|
||||||
isOpen = false;
|
OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]);
|
||||||
|
if (this.closeOnChoose) {
|
||||||
|
this.selectedItemTex?.Dispose();
|
||||||
|
isOpen = false;
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.Error($"Exception in Choose: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.PopStyleVar();
|
||||||
|
|
||||||
if (!this.closeOnChoose) {
|
if (!this.closeOnChoose) {
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (ImGui.Button(Loc.Localize("Close", "Close")))
|
if (ImGui.Button(Loc.Localize("Close", "Close")))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue