@@ -4164,8 +4164,14 @@ void TextEditor::renderFindReplace(ImVec2 pos, float width) {
41644164 }
41654165 }
41664166
4167- if (ImGui::IsItemDeactivated () && (ImGui::IsKeyPressed (ImGuiKey_Enter) || ImGui::IsKeyPressed (ImGuiKey_KeypadEnter))){
4168- focusOnEditor = true ;
4167+ if (ImGui::IsItemDeactivated ()) {
4168+ if (ImGui::IsKeyPressed (ImGuiKey_Escape)) {
4169+ closeFindReplace ();
4170+
4171+ } else if (ImGui::IsKeyPressed (ImGuiKey_Enter) || ImGui::IsKeyPressed (ImGuiKey_KeypadEnter)) {
4172+ focusOnEditor = true ;
4173+ focusOnFind = false ;
4174+ }
41694175 }
41704176
41714177 bool disableFindButtons = !findText.size ();
@@ -4417,8 +4423,8 @@ void TextEditor::openFindReplace() {
44174423
44184424void TextEditor::closeFindReplace () {
44194425 findReplaceVisible = false ;
4420- focusOnFind = false ;
44214426 focusOnEditor = true ;
4427+ focusOnFind = false ;
44224428}
44234429
44244430
@@ -4430,6 +4436,7 @@ void TextEditor::find() {
44304436 if (findText.size ()) {
44314437 selectNextOccurrenceOf (findText, caseSensitiveFind, wholeWordFind);
44324438 focusOnEditor = true ;
4439+ focusOnFind = false ;
44334440 }
44344441}
44354442
@@ -4442,6 +4449,7 @@ void TextEditor::findNext() {
44424449 if (findText.size ()) {
44434450 selectNextOccurrenceOf (findText, caseSensitiveFind, wholeWordFind);
44444451 focusOnEditor = true ;
4452+ focusOnFind = false ;
44454453 }
44464454}
44474455
@@ -4454,6 +4462,7 @@ void TextEditor::findAll() {
44544462 if (findText.size ()) {
44554463 selectAllOccurrencesOf (findText, caseSensitiveFind, wholeWordFind);
44564464 focusOnEditor = true ;
4465+ focusOnFind = false ;
44574466 }
44584467}
44594468
@@ -4471,6 +4480,7 @@ void TextEditor::replace() {
44714480 replaceTextInCurrentCursor (replaceText);
44724481 selectNextOccurrenceOf (findText, caseSensitiveFind, wholeWordFind);
44734482 focusOnEditor = true ;
4483+ focusOnFind = false ;
44744484 }
44754485}
44764486
@@ -4484,6 +4494,7 @@ void TextEditor::replaceAll() {
44844494 selectAllOccurrencesOf (findText, caseSensitiveFind, wholeWordFind);
44854495 replaceTextInAllCursors (replaceText);
44864496 focusOnEditor = true ;
4497+ focusOnFind = false ;
44874498 }
44884499}
44894500
0 commit comments