Skip to content

Commit

Permalink
UI|Home: Working on Home keyboard navigation
Browse files Browse the repository at this point in the history
Todo: Event handling while in menus still needs work.
  • Loading branch information
skyjake committed Aug 2, 2016
1 parent c8ad7b3 commit 2982511
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions doomsday/apps/client/include/ui/widgets/homeitemwidget.h
Expand Up @@ -69,6 +69,7 @@ class HomeItemWidget : public de::GuiWidget, public de::IAssetGroup
HomeMenuWidget *parentMenu();

// Events.
bool handleEvent(de::Event const &event) override;
void focusGained() override;
void focusLost() override;

Expand Down
16 changes: 16 additions & 0 deletions doomsday/apps/client/src/ui/widgets/homeitemwidget.cpp
Expand Up @@ -335,6 +335,22 @@ HomeMenuWidget *HomeItemWidget::parentMenu()
return parentWidget()->maybeAs<HomeMenuWidget>();
}

bool HomeItemWidget::handleEvent(Event const &event)
{
if (hasFocus() && event.isKey())
{
auto const &key = event.as<KeyEvent>();
if (key.ddKey() == DDKEY_LEFTARROW || key.ddKey() == DDKEY_RIGHTARROW ||
key.ddKey() == DDKEY_UPARROW || key.ddKey() == DDKEY_DOWNARROW)
{
// Fall back to menu and HomeWidget for navigation.
return false;
}
}

return GuiWidget::handleEvent(event);
}

void HomeItemWidget::focusGained()
{
setSelected(true);
Expand Down

0 comments on commit 2982511

Please sign in to comment.