Skip to content

Commit

Permalink
Shortcut click processing for screens beneath the screen that handled…
Browse files Browse the repository at this point in the history
… the event
  • Loading branch information
past-due committed Jan 11, 2021
1 parent 44da619 commit 10733e3
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions lib/widget/widget.cpp
Expand Up @@ -1017,7 +1017,7 @@ bool WIDGET::processClickRecursive(W_CONTEXT *psContext, WIDGET_KEY key, bool wa
// special case for root form
// since the processClickRecursive of children is only called if they are visible
// this should only trigger for the root form of a screen that's been set to invisible
return false;
return didProcessClick;
}

if (psMouseOverWidget.expired())
Expand Down Expand Up @@ -1045,11 +1045,17 @@ bool WIDGET::processClickRecursive(W_CONTEXT *psContext, WIDGET_KEY key, bool wa
// Note: There are rare exceptions where this can happen, if a WIDGET is doing something funky like drawing widgets it hasn't attached.
psMouseOverWidgetScreen = nullptr;
}

if (key == WKEY_NONE)
{
// We're just checking mouse position, and this isn't a click, but return that we handled it
return true;
}
}

if (key == WKEY_NONE)
{
return false; // Just checking mouse position, not a click.
return didProcessClick; // Just checking mouse position, not a click.
}

if (isMouseOverWidget())
Expand Down Expand Up @@ -1119,25 +1125,33 @@ WidgetTriggers const &widgRunScreen(const std::shared_ptr<W_SCREEN> &psScreen)
}
sContext.mx = c->pos.x;
sContext.my = c->pos.y;
forEachOverlayScreen([&sContext, wkey, pressed](const OverlayScreen& overlay) -> bool
bool didProcessClick = false;
forEachOverlayScreen([&sContext, &didProcessClick, wkey, pressed](const OverlayScreen& overlay) -> bool
{
overlay.psScreen->psForm->processClickRecursive(&sContext, wkey, pressed);
return true;
didProcessClick = overlay.psScreen->psForm->processClickRecursive(&sContext, wkey, pressed);
return !didProcessClick;
});
psScreen->psForm->processClickRecursive(&sContext, wkey, pressed);
if (!didProcessClick)
{
psScreen->psForm->processClickRecursive(&sContext, wkey, pressed);
}

lastReleasedKey_DEPRECATED = wkey;
}
}

sContext.mx = mouseX();
sContext.my = mouseY();
forEachOverlayScreen([&sContext](const OverlayScreen& overlay) -> bool
bool didProcessClick = false;
forEachOverlayScreen([&sContext, &didProcessClick](const OverlayScreen& overlay) -> bool
{
overlay.psScreen->psForm->processClickRecursive(&sContext, WKEY_NONE, true); // Update highlights and psMouseOverWidget.
return true;
didProcessClick = overlay.psScreen->psForm->processClickRecursive(&sContext, WKEY_NONE, true); // Update highlights and psMouseOverWidget.
return !didProcessClick;
});
psScreen->psForm->processClickRecursive(&sContext, WKEY_NONE, true); // Update highlights and psMouseOverWidget.
if (!didProcessClick)
{
psScreen->psForm->processClickRecursive(&sContext, WKEY_NONE, true); // Update highlights and psMouseOverWidget.
}
if (psMouseOverWidget.lock() == nullptr)
{
psMouseOverWidgetScreen.reset();
Expand Down

0 comments on commit 10733e3

Please sign in to comment.