Skip to content

Commit

Permalink
libappfw|libgui: Key modifier related cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 9, 2014
1 parent 9f83140 commit a5bae2b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doomsday/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -560,7 +560,7 @@ bool DialogWidget::handleEvent(Event const &event)
if(d->modality == Modal)
{
// The event should already have been handled by the children.
if((event.isKeyDown() && !(event.as<KeyEvent>().qtKey() == Qt::Key_Shift)) ||
if((event.isKeyDown() && !event.as<KeyEvent>().isModifier()) ||
(event.type() == Event::MouseButton &&
event.as<MouseEvent>().state() == MouseEvent::Pressed &&
!hitTest(event)))
Expand Down
10 changes: 8 additions & 2 deletions doomsday/libappfw/src/widgets/lineeditwidget.cpp
Expand Up @@ -423,6 +423,12 @@ bool LineEditWidget::handleEvent(Event const &event)
{
KeyEvent const &key = event.as<KeyEvent>();

if(key.isModifier())
{
// Don't eat modifier keys; the bindings system needs them.
return false;
}
/*
if(key.qtKey() == Qt::Key_Shift)
{
// Shift is not eaten so that Shift-Tilde can produce ~.
Expand All @@ -434,8 +440,8 @@ bool LineEditWidget::handleEvent(Event const &event)
key.qtKey() == Qt::Key_Meta)
{
// Modifier keys alone will be eaten when focused.
return true;
}
return false;
}*/

if(d->signalOnEnter && (key.qtKey() == Qt::Key_Enter || key.qtKey() == Qt::Key_Return))
{
Expand Down
1 change: 1 addition & 0 deletions doomsday/libgui/include/de/gui/keyevent.h
Expand Up @@ -64,6 +64,7 @@ class LIBGUI_PUBLIC KeyEvent : public de::Event
inline int nativeCode() const { return _nativeCode; }
inline de::String const &text() const { return _text; }
inline Modifiers modifiers() const { return _mods; }
bool isModifier() const;

/**
* Translates a Qt key code to a Doomsday key code (see ddkey.h).
Expand Down
6 changes: 6 additions & 0 deletions doomsday/libgui/src/keyevent.cpp
Expand Up @@ -430,4 +430,10 @@ KeyEvent::State KeyEvent::state() const
}
}

bool KeyEvent::isModifier() const
{
return _qtKey == Qt::Key_Shift || _qtKey == Qt::Key_Control ||
_qtKey == Qt::Key_Alt || _qtKey == Qt::Key_Meta;
}

} // namespace de

0 comments on commit a5bae2b

Please sign in to comment.