Closed probonopd closed 2 years ago
As I wrote earlier in https://github.com/helloSystem/Menu/issues/65#issuecomment-1279977618 the clearing is on purpose only implemented when a user changes application, so one can browse the filtered application menu. (btw there is QMenu::ABoutToHide) Perhaps the clear could happen only when a search result action is triggered? And/or the QLineEdit could have a clear button https://doc.qt.io/qt-5/qlineedit.html#clearButtonEnabled-prop
connect(m_searchMenu,&QMenu::aboutToHide,this,[this]{
searchLineEdit->clear();
searchLineEdit->textChanged("");
});
does the trick. But as you write, this essentially makes the filtering of the main (hoizontal) menu bar obsolete. I am not sure yet whether anyone will actually use the filtered main (hoizontal) menu bar, although it is an interesting idea.
Perhaps the clear could happen only when a search result action is triggered?
Yes, that'd be possible. Do you know where it would have to go for it to work like that?
And/or the QLineEdit could have a clear button
Something like this...
Could be done in addition, but personally I am always for simple solutions... I never had to click that button on the Mac.
This would be a small improvement:
connect(qApp, &QApplication::focusWindowChanged,
this, [this](QWindow *w) {
searchLineEdit->clear();
searchLineEdit->textChanged("");
});
The search is not cleared when the user moves the mouse from the "Search" menu title to menu items within "Search"
The search is cleared when the user leaves the Search menu entirely
Actually I am surprised that we are getting focusWindowChanged events if the user moves the cursor from the Search menu to other menus, and not only if the focus goes away from the Menu application MainWindow as a whole. Apparently Qt thinks of a menu as a "window"?
So this seems to get the job done:
connect(qApp, &QApplication::focusWindowChanged, this, [this](QWindow *w) {
if (!w) {
// Clean the search box if the user has left the Menu application altogether
searchLineEdit->clear();
searchLineEdit->textChanged("");
}
});
The search is not cleared when the user moves the mouse anywhere within the Menu application
The search is cleared when the user leaves the Menu application entirely or clicks in another menu
I am happy with this behavior now. You too @jsm222?
Currently the
searchLineEdit
only gets cleared when the user switches to another application.It should be cleared as soon as the Search menu is closed for whatever reason.
Do you know how to do this @jsm222?
probably we need to do
somewhere, but where? (I am looking for the equivalent of "onSearchMenuClosed" - do we need to use an event filter?)