diff options
| author | Mikolaj Boc <mikolaj.boc@qt.io> | 2023-02-02 15:43:50 +0100 |
|---|---|---|
| committer | Mikolaj Boc <mikolaj.boc@qt.io> | 2023-02-08 20:07:40 +0100 |
| commit | a1867208a654509c85a54914d1fe6178675c7fdc (patch) | |
| tree | 381a928a89101a73b7df4f3123da1656b20b3324 | |
| parent | d3dfe5a3b7e657b088f4e77e36b8d57229a13733 (diff) | |
| download | qtbase-a1867208a654509c85a54914d1fe6178675c7fdc.tar.gz | |
wasm: Don't grab menu bar item shortcuts on Mac
On Mac there's no concept of menu bar alt+key shortcuts. Therefore we
cannot expect users on Mac, even when in a web application, to be
familiar with those. Additionally, alt+key combinations yield special
characters on Mac so that is the behavior we should support in WASM apps
on Mac.
To disable the menu bar item shortcuts, a new platform style hint
UnderlineShortcut was created. Shortcut grabbing was disabled exactly
the same as on regular Mac builds, i.e. through
qt_set_sequence_auto_mnemonic.
Task-number: QTBUG-76587
Change-Id: Ice6ed123c01e46b58d6d2c3e639813161b5a9a40
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
| -rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index a88de18f2a..2bdb3b7c69 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -10,7 +10,7 @@ #include "qwasmaccessibility.h" #include "qwasmservices.h" #include "qwasmoffscreensurface.h" - +#include "qwasmplatform.h" #include "qwasmwindow.h" #include "qwasmbackingstore.h" #include "qwasmfontdatabase.h" @@ -32,6 +32,8 @@ QT_BEGIN_NAMESPACE +extern void qt_set_sequence_auto_mnemonic(bool); + using namespace emscripten; using namespace Qt::StringLiterals; @@ -81,6 +83,9 @@ QWasmIntegration::QWasmIntegration() { s_instance = this; + if (platform() == Platform::MacOS) + qt_set_sequence_auto_mnemonic(false); + touchPoints = emscripten::val::global("navigator")["maxTouchPoints"].as<int>(); // Create screens for container elements. Each container element will ultimately become a @@ -226,10 +231,14 @@ QAbstractEventDispatcher *QWasmIntegration::createEventDispatcher() const QVariant QWasmIntegration::styleHint(QPlatformIntegration::StyleHint hint) const { - if (hint == ShowIsFullScreen) + switch (hint) { + case ShowIsFullScreen: return true; - - return QPlatformIntegration::styleHint(hint); + case UnderlineShortcut: + return platform() != Platform::MacOS; + default: + return QPlatformIntegration::styleHint(hint); + } } Qt::WindowState QWasmIntegration::defaultWindowState(Qt::WindowFlags flags) const |
