Skip to content

Commit

Permalink
Widgets|libappfw: PanelButton does not always have to eat mouse events
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 2, 2017
1 parent c5b9f81 commit 280b95a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions doomsday/sdk/libappfw/include/de/widgets/panelwidget.h
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions doomsday/sdk/libappfw/src/widgets/panelwidget.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<MouseEvent>();

Expand All @@ -335,7 +341,6 @@ bool PanelWidget::handleEvent(Event const &event)
return true;
}
}

return GuiWidget::handleEvent(event);
}

Expand Down

0 comments on commit 280b95a

Please sign in to comment.