typingEvent fix,double characters when focus

This commit is contained in:
yifang 2021-12-16 22:46:21 +08:00 committed by xiaoyifang
parent de3d7b8b19
commit 5860e81ff3
2 changed files with 11 additions and 9 deletions

View file

@ -2583,7 +2583,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
else else
if ( obj == wordList ) if ( obj == wordList )
{ {
if ( ev->type() == QEvent::KeyPress ) if (ev->type() == QEvent::KeyPress || ev->type() == QEvent::ShortcutOverride)
{ {
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev ); QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
@ -2634,7 +2634,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
} }
else else
if (obj == ui.dictsList) { if (obj == ui.dictsList) {
if ( ev->type() == QEvent::KeyPress ) if ( ev->type() == QEvent::KeyPress || ev->type() == QEvent::ShortcutOverride)
{ {
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev ); QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
@ -2768,10 +2768,11 @@ void MainWindow::typingEvent( QString const & t )
if( translateLine->isEnabled() ) if( translateLine->isEnabled() )
{ {
//translateLine->setFocus(); translateLine->clear();
// Escaping the typed-in characters is the user's responsibility. translateLine->setFocus();
setTranslateBoxTextAndClearSuffix( t, WildcardsAreAlreadyEscaped, EnablePopup ); // Escaping the typed-in characters is the user's responsibility.
translateLine->setCursorPosition( t.size() ); // setTranslateBoxTextAndClearSuffix( t, WildcardsAreAlreadyEscaped, EnablePopup );
// translateLine->setCursorPosition( t.size() );
} }
} }
} }

View file

@ -856,9 +856,10 @@ void ScanPopup::typingEvent( QString const & t )
} }
else else
{ {
ui.translateBox->translateLine()->setFocus(); ui.translateBox->translateLine()->clear();
ui.translateBox->setText( t, true ); ui.translateBox->translateLine()->setFocus();
ui.translateBox->translateLine()->setCursorPosition( t.size() ); // ui.translateBox->setText( t, true );
// ui.translateBox->translateLine()->setCursorPosition( t.size() );
} }
} }