Skip to content

Commit 30f1c97

Browse files
committed
Allow navigation of character widget with arrow cursor keys
1 parent bd13c36 commit 30f1c97

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

src/gui/symbology/characterwidget.cpp

+39-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,45 @@ QSize CharacterWidget::sizeHint() const
139139

140140
void CharacterWidget::keyPressEvent( QKeyEvent *event )
141141
{
142-
if ( !event->text().isEmpty() )
142+
QFontMetrics fm( mDisplayFont );
143+
144+
if ( event->key() == Qt::Key_Right )
145+
{
146+
int next = std::min( mLastKey + 1, 0xfffc );
147+
while ( next < 0xfffc && !fm.inFont( QChar( next ) ) )
148+
{
149+
next++;
150+
}
151+
setCharacter( QChar( next ) );
152+
}
153+
else if ( event->key() == Qt::Key_Left )
154+
{
155+
int next = mLastKey - 1;
156+
while ( next > 0 && !fm.inFont( QChar( next ) ) )
157+
{
158+
next--;
159+
}
160+
setCharacter( QChar( next ) );
161+
}
162+
else if ( event->key() == Qt::Key_Down )
163+
{
164+
int next = std::min( mLastKey + mColumns, 0xfffc );
165+
while ( next < 0xfffc && !fm.inFont( QChar( next ) ) )
166+
{
167+
next = std::min( next + mColumns, 0xfffc );
168+
}
169+
setCharacter( QChar( next ) );
170+
}
171+
else if ( event->key() == Qt::Key_Up )
172+
{
173+
int next = std::max( 0, mLastKey - mColumns );
174+
while ( next > 0 && !fm.inFont( QChar( next ) ) )
175+
{
176+
next = std::max( 0, next - mColumns );
177+
}
178+
setCharacter( QChar( next ) );
179+
}
180+
else if ( !event->text().isEmpty() )
143181
{
144182
QChar chr = event->text().at( 0 );
145183
if ( chr.unicode() != mLastKey )

0 commit comments

Comments
 (0)