Skip to content

Commit

Permalink
Fixed|Input|Bindings: Activate "console" bcontext when console has focus
Browse files Browse the repository at this point in the history
Otherwise key modifiers might fire the gun, etc. when typing in the
console.
  • Loading branch information
skyjake committed Apr 17, 2014
1 parent c77db95 commit 194684a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doomsday/client/include/ui/widgetactions.h
Expand Up @@ -73,6 +73,12 @@ class WidgetActions
*/
void trackInput(de::Event const &event);

void activateContext(de::String const &context, bool yes = true);

void deactivateContext(de::String const &context) {
activateContext(context, false);
}

private:
DENG2_PRIVATE(d)
};
Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/include/ui/widgets/consolecommandwidget.h
Expand Up @@ -36,6 +36,8 @@ class ConsoleCommandWidget : public de::CommandWidget
ConsoleCommandWidget(de::String const &name = "");

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

protected:
Expand Down
8 changes: 8 additions & 0 deletions doomsday/client/src/ui/widgetactions.cpp
Expand Up @@ -81,3 +81,11 @@ void WidgetActions::trackInput(Event const &event)
DD_ConvertEvent(event, &ddev);
I_TrackInput(&ddev);
}

void WidgetActions::activateContext(String const &context, bool yes)
{
if(bcontext_t *bc = B_ContextByName(context.toLatin1()))
{
B_ActivateContext(bc, yes);
}
}
12 changes: 12 additions & 0 deletions doomsday/client/src/ui/widgets/consolecommandwidget.cpp
Expand Up @@ -64,6 +64,18 @@ ConsoleCommandWidget::ConsoleCommandWidget(String const &name)
d->updateLexicon();
}

void ConsoleCommandWidget::focusGained()
{
CommandWidget::focusGained();
ClientApp::widgetActions().activateContext("console");
}

void ConsoleCommandWidget::focusLost()
{
CommandWidget::focusLost();
ClientApp::widgetActions().deactivateContext("console");
}

bool ConsoleCommandWidget::handleEvent(Event const &event)
{
if(isDisabled()) return false;
Expand Down

0 comments on commit 194684a

Please sign in to comment.