@@ -139,7 +139,45 @@ QSize CharacterWidget::sizeHint() const
139
139
140
140
void CharacterWidget::keyPressEvent ( QKeyEvent *event )
141
141
{
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 () )
143
181
{
144
182
QChar chr = event->text ().at ( 0 );
145
183
if ( chr.unicode () != mLastKey )
0 commit comments