Skip to content

Commit

Permalink
Client|LineEditWidget: Use key modifiers (word jumping)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 24, 2013
1 parent 887dc30 commit 9098153
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doomsday/client/include/ui/widgets/lineeditwidget.h
Expand Up @@ -21,6 +21,7 @@

#include "guiwidget.h"
#include <de/shell/AbstractLineEditor>
#include <de/KeyEvent>

/**
* Widget showing a lineedit text and/or image.
Expand Down Expand Up @@ -50,6 +51,9 @@ class LineEditWidget : public GuiWidget, public de::shell::AbstractLineEditor
void drawContent();
bool handleEvent(de::Event const &event);

public:
static KeyModifiers modifiersFromKeyEvent(de::KeyEvent::Modifiers const &keyMods);

protected:
void glInit();
void glDeinit();
Expand Down
14 changes: 13 additions & 1 deletion doomsday/client/src/ui/widgets/lineeditwidget.cpp
Expand Up @@ -384,7 +384,7 @@ bool LineEditWidget::handleEvent(Event const &event)
KeyEvent const &key = event.as<KeyEvent>();

// Control character.
if(handleControlKey(key.qtKey(), key.modifiers().testFlag(KeyEvent::Control)))
if(handleControlKey(key.qtKey(), modifiersFromKeyEvent(key.modifiers())))
{
return true;
}
Expand All @@ -401,6 +401,18 @@ bool LineEditWidget::handleEvent(Event const &event)
return GuiWidget::handleEvent(event);
}

shell::AbstractLineEditor::KeyModifiers LineEditWidget::modifiersFromKeyEvent(KeyEvent::Modifiers const &keyMods)
{
KeyModifiers mods;

if(keyMods.testFlag(KeyEvent::Shift)) mods |= Shift;
if(keyMods.testFlag(KeyEvent::Control)) mods |= Control;
if(keyMods.testFlag(KeyEvent::Alt)) mods |= Alt;
if(keyMods.testFlag(KeyEvent::Meta)) mods |= Meta;

return mods;
}

int LineEditWidget::maximumWidth() const
{
return rule().recti().width() - 2 * d->margin;
Expand Down

1 comment on commit 9098153

@danij-deng
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor issues:

  • Pressing a modifier key with the task bar open and the input command line focused presently opens the game menu
  • When word jumping if the command line is "rend-" the cursor won't jump over the hypen at the end

Please sign in to comment.