mirror of https://github.com/WerWolv/ImHex.git
fix: Command Palette focus not working
This commit is contained in:
parent
fc20d751bb
commit
d0f1a40f16
|
@ -28,15 +28,24 @@ namespace hex::plugin::builtin {
|
||||||
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
|
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
|
||||||
|
if (this->m_focusInputTextBox) {
|
||||||
|
auto textState = ImGui::GetInputTextState(ImGui::GetID("##command_input"));
|
||||||
|
if (textState != nullptr) {
|
||||||
|
textState->Stb.cursor = strlen(this->m_commandBuffer.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SetKeyboardFocusHere(0);
|
||||||
|
this->m_focusInputTextBox = false;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::PushItemWidth(-1);
|
ImGui::PushItemWidth(-1);
|
||||||
if (ImGui::InputText(
|
if (ImGui::InputText("##command_input", this->m_commandBuffer.data(), this->m_commandBuffer.size(), ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_EnterReturnsTrue,
|
||||||
"##command_input", this->m_commandBuffer.data(), this->m_commandBuffer.size(), ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_EnterReturnsTrue, [](ImGuiInputTextCallbackData *callbackData) -> int {
|
[](ImGuiInputTextCallbackData *callbackData) -> int {
|
||||||
auto _this = static_cast<ViewCommandPalette *>(callbackData->UserData);
|
auto _this = static_cast<ViewCommandPalette *>(callbackData->UserData);
|
||||||
_this->m_lastResults = _this->getCommandResults(callbackData->Buf);
|
_this->m_lastResults = _this->getCommandResults(callbackData->Buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
},
|
}, this)) {
|
||||||
this)) {
|
|
||||||
if (!this->m_lastResults.empty()) {
|
if (!this->m_lastResults.empty()) {
|
||||||
auto &[displayResult, matchedCommand, callback] = this->m_lastResults.front();
|
auto &[displayResult, matchedCommand, callback] = this->m_lastResults.front();
|
||||||
callback(matchedCommand);
|
callback(matchedCommand);
|
||||||
|
@ -52,16 +61,6 @@ namespace hex::plugin::builtin {
|
||||||
this->m_justOpened = false;
|
this->m_justOpened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->m_focusInputTextBox) {
|
|
||||||
auto textState = ImGui::GetInputTextState(ImGui::GetID("##command_input"));
|
|
||||||
if (textState != nullptr) {
|
|
||||||
textState->Stb.cursor = strlen(this->m_commandBuffer.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SetKeyboardFocusHere(0);
|
|
||||||
this->m_focusInputTextBox = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
for (const auto &[displayResult, matchedCommand, callback] : this->m_lastResults) {
|
for (const auto &[displayResult, matchedCommand, callback] : this->m_lastResults) {
|
||||||
|
|
Loading…
Reference in New Issue