mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-16 17:00:35 +03:00
LibGUI: CommandPalette: Fix key event capture for actions
This patch fixes an issue for applications that contain actions without a modifier (e.g. PixelPaint). Previously when pressing any key bound to an action while the CommandPalette was visible the action was forwarded to the parent instead of the CommandPalette.
This commit is contained in:
parent
5ff63a9eb0
commit
d91469ebb1
Notes:
sideshowbarker
2024-07-18 03:35:30 +09:00
Author: https://github.com/faxe1008 Commit: https://github.com/SerenityOS/serenity/commit/d91469ebb1 Pull-request: https://github.com/SerenityOS/serenity/pull/15129 Reviewed-by: https://github.com/thankyouverycool ✅
@ -223,8 +223,8 @@ CommandPalette::CommandPalette(GUI::Window& parent_window, ScreenPosition screen
|
||||
|
||||
m_text_box->set_focus(true);
|
||||
|
||||
on_active_window_change = [this](bool is_active_window) {
|
||||
if (!is_active_window)
|
||||
on_active_input_change = [this](bool is_active_input) {
|
||||
if (!is_active_input)
|
||||
close();
|
||||
};
|
||||
|
||||
|
@ -164,7 +164,7 @@ static Action* action_for_shortcut(Window& window, Shortcut const& shortcut)
|
||||
}
|
||||
|
||||
// NOTE: Application-global shortcuts are ignored while a blocking modal window is up.
|
||||
if (!window.is_blocking()) {
|
||||
if (!window.is_blocking() && !window.is_capturing_input()) {
|
||||
if (auto* action = Application::the()->action_for_shortcut(shortcut)) {
|
||||
dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Asked application, got action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", action, action->text(), action->is_enabled(), action->shortcut().to_string(), action->alternate_shortcut().to_string());
|
||||
return action;
|
||||
@ -214,7 +214,7 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key,
|
||||
// FIXME: This shortcut should be configurable.
|
||||
if (accepts_command_palette && !m_in_command_palette && modifiers == (Mod_Ctrl | Mod_Shift) && key == Key_A) {
|
||||
auto command_palette = CommandPalette::construct(*window);
|
||||
command_palette->set_window_mode(GUI::WindowMode::Passive);
|
||||
command_palette->set_window_mode(GUI::WindowMode::CaptureInput);
|
||||
TemporaryChange change { m_in_command_palette, true };
|
||||
if (command_palette->exec() != GUI::Dialog::ExecResult::OK)
|
||||
return;
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
|
||||
bool is_modal() const { return m_window_mode != WindowMode::Modeless; }
|
||||
bool is_blocking() const { return m_window_mode == WindowMode::Blocking; }
|
||||
bool is_capturing_input() const { return m_window_mode == WindowMode::CaptureInput; }
|
||||
|
||||
bool is_fullscreen() const { return m_fullscreen; }
|
||||
void set_fullscreen(bool);
|
||||
|
Loading…
Reference in New Issue
Block a user