From 41e74d4d31796ff4aac01ce884d6c866a214a71c Mon Sep 17 00:00:00 2001 From: Marcus Nilsson Date: Wed, 19 May 2021 22:11:59 +0200 Subject: [PATCH] CatDog: Don't show context menu when clicking outside of widget The context menu for CatDog was shown when right clicking anywhere on the screen because of global cursor tracking being enabled. Also fix event not being passed by reference. Fixes #7285 --- Userland/Demos/CatDog/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Demos/CatDog/main.cpp b/Userland/Demos/CatDog/main.cpp index c98108c28e..ac6c2aae36 100644 --- a/Userland/Demos/CatDog/main.cpp +++ b/Userland/Demos/CatDog/main.cpp @@ -101,8 +101,9 @@ int main(int argc, char** argv) advice_timer->start(); }; - catdog_widget.on_context_menu_request = [&](GUI::ContextMenuEvent event) { - context_menu->popup(event.screen_position()); + catdog_widget.on_context_menu_request = [&](GUI::ContextMenuEvent& event) { + if (catdog_widget.rect().contains(event.position())) + context_menu->popup(event.screen_position()); }; return app->exec();