Skip to content

Commit

Permalink
HackStudio: Make locator lose focus on close
Browse files Browse the repository at this point in the history
Make locator lose focus when pressing escape or by clicking in the
editor area.
  • Loading branch information
metmo authored and linusg committed Jun 2, 2021
1 parent b43dad1 commit 3931b29
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Userland/DevTools/HackStudio/Locator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ Locator::Locator(Core::Object* parent)
m_textbox->on_change = [this] {
update_suggestions();
};

m_textbox->on_escape_pressed = [this] {
m_popup_window->hide();
m_textbox->set_focus(false);
};

m_textbox->on_up_pressed = [this] {
GUI::ModelIndex new_index = m_suggestion_view->selection().first();
if (new_index.is_valid())
Expand Down Expand Up @@ -138,6 +141,10 @@ Locator::Locator(Core::Object* parent)
open_suggestion(selected_index);
};

m_textbox->on_focusout = [&]() {
close();
};

m_popup_window = GUI::Window::construct(parent);
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
m_popup_window->set_window_type(GUI::WindowType::Tooltip);
Expand Down

0 comments on commit 3931b29

Please sign in to comment.