mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
fix: Unavailable menu items still being visible in the command palette
This commit is contained in:
@@ -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); });
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user