From f35238706e90adef55450e93b4abdeea9c9aa3bb Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Sun, 29 Oct 2023 18:38:46 +0200 Subject: [PATCH] Improve keyboard events - Closing with Escape now works when a listview widget has the focus. - Starting typing while the focus is not on the search lineedit now automatically gives focus to the search lineedit. Signed-off-by: Mavridis Philippe --- src/menuhandler.cpp | 10 +++++++--- src/tastylistview.cpp | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/menuhandler.cpp b/src/menuhandler.cpp index f461e7c..05ea617 100644 --- a/src/menuhandler.cpp +++ b/src/menuhandler.cpp @@ -101,6 +101,7 @@ MenuHandler::MenuHandler( TQWidget *parent, Prefs *prefs, char *name, WFlags fl) menu->searchLine->setContextMenuEnabled(false); //event filters for keyboard navigation + menu->installEventFilter(this); menu->clearButton->installEventFilter(this); menu->searchLine->installEventFilter(this); menu->menuModes->installEventFilter(this); @@ -304,10 +305,8 @@ bool MenuHandler::eventFilter( TQObject *o, TQEvent * e ) TQKeyEvent *keyEvent = (TQKeyEvent *)e; TQFocusData *fData = focusData(); fData->home(); - switch( keyEvent->key() ) { - case TQt::Key_Up: if( dynamic_cast(o) ) return false; @@ -381,7 +380,12 @@ bool MenuHandler::eventFilter( TQObject *o, TQEvent * e ) close(); default: - return false; + if (!keyEvent->text().isNull() && !menu->searchLine->hasFocus()) { + menu->searchLine->setText(keyEvent->text()); + menu->searchLine->setFocus(); + return true; + } + else return false; } return true; } diff --git a/src/tastylistview.cpp b/src/tastylistview.cpp index f958bfc..4448528 100644 --- a/src/tastylistview.cpp +++ b/src/tastylistview.cpp @@ -208,6 +208,7 @@ void TastyListView::keyPressEvent( TQKeyEvent * e ) break; default: + e->ignore(); break; } }