mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14: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();
|
||||
|
||||
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) {
|
||||
OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]);
|
||||
// Darken choose button if it shouldn't be clickable
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 ? 0.25f : 1);
|
||||
|
||||
if (this.closeOnChoose) {
|
||||
this.selectedItemTex?.Dispose();
|
||||
isOpen = false;
|
||||
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) {
|
||||
try {
|
||||
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) {
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button(Loc.Localize("Close", "Close")))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue