Skip to content

Commit

Permalink
fixed #1016, '@' key press didn't activate command box
Browse files Browse the repository at this point in the history
  • Loading branch information
lordofbikes committed Oct 11, 2018
1 parent b8e2a3c commit d779df2
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions librecad/src/ui/forms/qg_commandwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ void QG_CommandWidget::languageChange()

bool QG_CommandWidget::eventFilter(QObject */*obj*/, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent* e=static_cast<QKeyEvent*>(event);
if (event->type() == QEvent::KeyPress) {
QKeyEvent* e=static_cast<QKeyEvent*>(event);

switch(e->key())
{
int key {e->key()};
switch(key) {
case Qt::Key_Return:
case Qt::Key_Enter:
if(!leCommand->text().size())
Expand All @@ -118,22 +117,28 @@ bool QG_CommandWidget::eventFilter(QObject */*obj*/, QEvent *event)
return false;
default:
break;
}
}

//detect Ctl- Alt- modifier, but not Shift
//This should avoid filtering shortcuts, such as Ctl-C
RS_DEBUG->print(RS_Debug::D_CRITICAL, "QG_CommandWidget::eventFilter(): key %d mod 0x%08X", e->key(), e->modifiers());

if (e->modifiers() != Qt::KeypadModifier
&& e->modifiers() & (Qt::KeyboardModifierMask ^ Qt::ShiftModifier))
Qt::KeyboardModifiers modifiers {e->modifiers()};
if ( !(Qt::GroupSwitchModifier == modifiers && Qt::Key_At == key) // let '@' key pass for relative coords
&& modifiers != Qt::KeypadModifier
&& modifiers & (Qt::KeyboardModifierMask ^ Qt::ShiftModifier)) {
return false;
}

event->accept();
event->accept();
this->setFocus();
QKeyEvent * newEvent = new QKeyEvent(*static_cast<QKeyEvent*>(event));
QApplication::postEvent(leCommand, newEvent);
return true;
}
return false;

return true;
}

return false;
}

void QG_CommandWidget::setFocus()
Expand Down

0 comments on commit d779df2

Please sign in to comment.