fix: Unavailable menu items still being visible in the command palette

This commit is contained in:
WerWolv
2025-08-06 22:20:31 +02:00
parent abe13d9ff9
commit 31322bcc76
2 changed files with 14 additions and 1 deletions

View File

@@ -4,6 +4,8 @@
#include <hex/api/localization_manager.hpp>
#include <hex/api/shortcut_manager.hpp>
#include <hex/ui/view.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fmt.hpp>
#include <hex/providers/provider.hpp>
@@ -358,6 +360,11 @@ namespace hex::plugin::builtin {
if (!entry.enabledCallback())
continue;
if (entry.view != nullptr) {
if (View::getLastFocusedView() != entry.view)
continue;
}
std::vector<std::string> names;
std::transform(entry.unlocalizedNames.begin(), entry.unlocalizedNames.end(), std::back_inserter(names), [](auto &name) { return Lang(name); });

View File

@@ -118,9 +118,15 @@ namespace hex::plugin::builtin {
// Draw the results
if (ImGui::BeginChild("##results", ImGui::GetContentRegionAvail(), ImGuiChildFlags_NavFlattened, ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
u32 id = 1;
for (const auto &[displayResult, matchedCommand, callback] : m_lastResults) {
ImGui::PushID(id);
ImGui::PushItemFlag(ImGuiItemFlags_NoTabStop, false);
ON_SCOPE_EXIT { ImGui::PopItemFlag(); };
ON_SCOPE_EXIT {
ImGui::PopItemFlag();
ImGui::PopID();
id += 1;
};
// Allow executing a command by clicking on it or selecting it with the keyboard and pressing enter
if (ImGui::Selectable(displayResult.c_str(), false, ImGuiSelectableFlags_NoAutoClosePopups)) {