Skip to content

Commit

Permalink
Fixed handling of arrow keys on focused layer combo box
Browse files Browse the repository at this point in the history
Using the arrow keys with the combo box selected only changed the layer
shown in the combo box, but failed to actually change the selected
layer.

Closes #1973
  • Loading branch information
bjorn committed Jul 13, 2018
1 parent 3aac57d commit f308463
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/tiled/treeviewcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,32 @@ void TreeViewComboBox::wheelEvent(QWheelEvent *e)

void TreeViewComboBox::keyPressEvent(QKeyEvent *e)
{
QModelIndex index;

if (e->key() == Qt::Key_Up || e->key() == Qt::Key_PageUp) {
setCurrentModelIndex(indexAbove(m_view->currentIndex()));
index = indexAbove(m_view->currentIndex());
} else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_PageDown) {
setCurrentModelIndex(indexBelow(m_view->currentIndex()));
index = indexBelow(m_view->currentIndex());
} else if (e->key() == Qt::Key_Home) {
QModelIndex index = m_view->model()->index(0, 0);
index = m_view->model()->index(0, 0);
if (index.isValid() && !(model()->flags(index) & Qt::ItemIsSelectable))
index = indexBelow(index);
setCurrentModelIndex(index);
} else if (e->key() == Qt::Key_End) {
QModelIndex index = lastIndex(m_view->rootIndex());
index = lastIndex(m_view->rootIndex());
if (index.isValid() && !(model()->flags(index) & Qt::ItemIsSelectable))
index = indexAbove(index);
setCurrentModelIndex(index);
} else {
QComboBox::keyPressEvent(e);
return;
}

if (index.isValid()) {
setCurrentModelIndex(index);

// for compatibility we emit activated with a useless row parameter
emit activated(index.row());
}

e->accept();
}

Expand Down

0 comments on commit f308463

Please sign in to comment.