From 280b95ad7f09289ba0a852086cb17a81c1f36510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Thu, 2 Feb 2017 23:58:24 +0200 Subject: [PATCH] Widgets|libappfw: PanelButton does not always have to eat mouse events --- doomsday/sdk/libappfw/include/de/widgets/panelwidget.h | 7 +++++++ doomsday/sdk/libappfw/src/widgets/panelwidget.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doomsday/sdk/libappfw/include/de/widgets/panelwidget.h b/doomsday/sdk/libappfw/include/de/widgets/panelwidget.h index 298a6b0d4a..715dae6d8c 100644 --- a/doomsday/sdk/libappfw/include/de/widgets/panelwidget.h +++ b/doomsday/sdk/libappfw/include/de/widgets/panelwidget.h @@ -54,6 +54,13 @@ class LIBAPPFW_PUBLIC PanelWidget : public GuiWidget void setWaitForContentReady(bool yes); + /** + * Enables or disables mouse event eating. The default is that a panel eats + * events that hit it. + * @param yes @c true to enable. + */ + void setEatMouseEvents(bool yes); + /** * Sets the size policy for the secondary dimension. For instance, for a * panel that opens horizontally, this determines what is done to the diff --git a/doomsday/sdk/libappfw/src/widgets/panelwidget.cpp b/doomsday/sdk/libappfw/src/widgets/panelwidget.cpp index 00572ad8e9..f9abd0eabf 100644 --- a/doomsday/sdk/libappfw/src/widgets/panelwidget.cpp +++ b/doomsday/sdk/libappfw/src/widgets/panelwidget.cpp @@ -38,6 +38,7 @@ DENG_GUI_PIMPL(PanelWidget) typedef DefaultVertexBuf VertexBuf; bool waitForContentReady = true; + bool eatMouseEvents = true; bool opened = false; ui::Direction dir = ui::Down; ui::SizePolicy secondaryPolicy = ui::Expand; @@ -236,6 +237,11 @@ void PanelWidget::setWaitForContentReady(bool yes) d->waitForContentReady = yes; } +void de::PanelWidget::setEatMouseEvents(bool yes) +{ + d->eatMouseEvents = yes; +} + void PanelWidget::setContent(GuiWidget *content) { if (d->content) @@ -324,7 +330,7 @@ void PanelWidget::update() bool PanelWidget::handleEvent(Event const &event) { - if (event.type() == Event::MouseButton) + if (d->eatMouseEvents && event.type() == Event::MouseButton) { MouseEvent const &mouse = event.as(); @@ -335,7 +341,6 @@ bool PanelWidget::handleEvent(Event const &event) return true; } } - return GuiWidget::handleEvent(event); }