Skip to content
Permalink
Browse files

Allow navigation of character widget with arrow cursor keys

  • Loading branch information
nyalldawson committed May 1, 2019
1 parent bd13c36 commit 30f1c97341b927afad492871400099baa29ae757
Showing with 39 additions and 1 deletion.
  1. +39 −1 src/gui/symbology/characterwidget.cpp
@@ -139,7 +139,45 @@ QSize CharacterWidget::sizeHint() const

void CharacterWidget::keyPressEvent( QKeyEvent *event )
{
if ( !event->text().isEmpty() )
QFontMetrics fm( mDisplayFont );

if ( event->key() == Qt::Key_Right )
{
int next = std::min( mLastKey + 1, 0xfffc );
while ( next < 0xfffc && !fm.inFont( QChar( next ) ) )
{
next++;
}
setCharacter( QChar( next ) );
}
else if ( event->key() == Qt::Key_Left )
{
int next = mLastKey - 1;
while ( next > 0 && !fm.inFont( QChar( next ) ) )
{
next--;
}
setCharacter( QChar( next ) );
}
else if ( event->key() == Qt::Key_Down )
{
int next = std::min( mLastKey + mColumns, 0xfffc );
while ( next < 0xfffc && !fm.inFont( QChar( next ) ) )
{
next = std::min( next + mColumns, 0xfffc );
}
setCharacter( QChar( next ) );
}
else if ( event->key() == Qt::Key_Up )
{
int next = std::max( 0, mLastKey - mColumns );
while ( next > 0 && !fm.inFont( QChar( next ) ) )
{
next = std::max( 0, next - mColumns );
}
setCharacter( QChar( next ) );
}
else if ( !event->text().isEmpty() )
{
QChar chr = event->text().at( 0 );
if ( chr.unicode() != mLastKey )

0 comments on commit 30f1c97

Please sign in to comment.
You can’t perform that action at this time.