Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4032,8 +4032,10 @@ bool MuseScoreApplication::event(QEvent* event)

void MuseScore::focusScoreView()
{
if (currentScoreView())
if (currentScoreView()) {
currentScoreView()->activateWindow();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, this allows for pressing ESCAPE and from within the search string while floating and have the score resume focus. Unfortunately doesn't work without this PR/Commit.

currentScoreView()->setFocus();
}
else
mscore->setFocus();
}
Expand Down
10 changes: 7 additions & 3 deletions mscore/palette/palettewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "qml/nativetooltip.h"

#include <QQmlContext>
#include <QTimer>

namespace Ms {

Expand Down Expand Up @@ -119,10 +120,13 @@ void PaletteWidget::setupStyle()

void PaletteWidget::activateSearchBox()
{
int delay = isFloating() ? 300 : 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May seem strange, but when palette is floating, the focus in event ends up occuring "after" the focus in event of the searchText and ends up then removing the preparation for search string. Adding a slight delay to the request only when floating clears this up

ensureQmlViewFocused();
const bool invoked = QMetaObject::invokeMethod(rootObject(), "requestPaletteSearch");
Q_UNUSED(invoked);
Q_ASSERT(invoked);
QTimer::singleShot(delay, this, [&](){
const bool invoked = QMetaObject::invokeMethod(rootObject(), "requestPaletteSearch");
Q_UNUSED(invoked);
Q_ASSERT(invoked);
});
}

//---------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion mscore/qmldockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ QQuickView* QmlDockWidget::getView()

void QmlDockWidget::ensureQmlViewFocused()
{
if (_view && !_view->activeFocusItem())
if (_view && !_view->activeFocusItem()) {
widget()->activateWindow();
Copy link
Contributor Author

@worldwideweary worldwideweary Nov 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ends up allowing using the search shortcut while floating. Unfortunately took quite some time for me to figure this out, even though it's only one function call extra.

widget()->setFocus();
}
}

//---------------------------------------------------------
Expand Down