ux: Change "Esc" key behavior on hex editor popups (#810)

* set same behaviour for PopupGoto and PopupFind

* Force close the popup when user is editing an input
This commit is contained in:
iTrooz_ 2022-11-01 09:33:11 +01:00 committed by GitHub
parent 6cb9714f06
commit 948b5b2d9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -44,8 +44,10 @@ namespace hex::plugin::builtin {
ImGui::EndTabItem();
}
ImGui::SetKeyboardFocusHere();
ImGui::SetNextFrameWantCaptureKeyboard(true);
if(this->m_requestFocus){
ImGui::SetKeyboardFocusHere();
this->m_requestFocus = false;
}
if (ImGui::InputTextIcon("##input", ICON_VS_SYMBOL_OPERATOR, this->m_input, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll)) {
if (auto result = this->m_evaluator.evaluate(this->m_input); result.has_value()) {
const auto inputResult = result.value();
@ -92,6 +94,7 @@ namespace hex::plugin::builtin {
Mode m_mode = Mode::Absolute;
bool m_requestFocus = true;
std::string m_input;
MathEvaluator<i128> m_evaluator;
};
@ -781,6 +784,11 @@ namespace hex::plugin::builtin {
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin() - ImGui::GetStyle().WindowPadding, ImGuiCond_Appearing);
if (ImGui::BeginPopup("##hex_editor_popup", ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |ImGuiWindowFlags_NoTitleBar)) {
// Force close the popup when user is editing an input
if(ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))){
ImGui::CloseCurrentPopup();
}
if (this->m_currPopup != nullptr)
this->m_currPopup->draw(this);