Windows QPA: Allow the native Windows virtual keyboard to be disabled
This change provides a way to disable the automatic showing of the native Windows on-screen virtual keyboard when a text editing widget is selected on a system without a physical keyboard, by enabling the new AA_MSWindowsDisableVirtualKeyboard application attribute, allowing applications to use a custom virtual keyboard implementation. Fixes: QTBUG-76088 Change-Id: Id76f9673a2e4081e5325662f3e3b4b102d133b9a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>bb10
parent
abbdd634cd
commit
18f22fea7c
|
|
@ -523,6 +523,7 @@ public:
|
|||
AA_DontUseNativeMenuBar = 6,
|
||||
AA_MacDontSwapCtrlAndMeta = 7,
|
||||
AA_Use96Dpi = 8,
|
||||
AA_MSWindowsDisableVirtualKeyboard = 9,
|
||||
#if QT_DEPRECATED_SINCE(5, 14)
|
||||
AA_X11InitThreads Q_DECL_ENUMERATOR_DEPRECATED = 10,
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -293,6 +293,12 @@
|
|||
This attribute must be set before QGuiApplication is constructed.
|
||||
This value was added in 5.13
|
||||
|
||||
\value AA_MSWindowsDisableVirtualKeyboard When this attribute is set,
|
||||
Windows' native on-screen virtual keyboard will not be shown
|
||||
automatically when a text input widget gains focus on a system
|
||||
without a physical keyboard.
|
||||
This value was added in 5.15
|
||||
|
||||
The following values are deprecated or obsolete:
|
||||
|
||||
\value AA_ImmediateWidgetCreation This attribute is no longer fully
|
||||
|
|
|
|||
|
|
@ -285,7 +285,8 @@ void QWindowsInputContext::showInputPanel()
|
|||
// the Surface seems unnecessary there anyway. But leave it hidden for IME.
|
||||
// Only trigger the native OSK if the Qt OSK is not in use.
|
||||
static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE");
|
||||
if (imModuleEmpty
|
||||
bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard);
|
||||
if ((imModuleEmpty && !nativeVKDisabled)
|
||||
&& QOperatingSystemVersion::current()
|
||||
>= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) {
|
||||
ShowCaret(platformWindow->handle());
|
||||
|
|
|
|||
|
|
@ -393,12 +393,14 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR
|
|||
// Control type converted from role.
|
||||
auto controlType = roleToControlTypeId(accessible->role());
|
||||
|
||||
// The native OSK should be disbled if the Qt OSK is in use.
|
||||
// The native OSK should be disbled if the Qt OSK is in use,
|
||||
// or if disabled via application attribute.
|
||||
static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE");
|
||||
bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard);
|
||||
|
||||
// If we want to disable the native OSK auto-showing
|
||||
// we have to report text fields as non-editable.
|
||||
if (controlType == UIA_EditControlTypeId && !imModuleEmpty)
|
||||
if (controlType == UIA_EditControlTypeId && (!imModuleEmpty || nativeVKDisabled))
|
||||
controlType = UIA_TextControlTypeId;
|
||||
|
||||
setVariantI4(controlType, pRetVal);
|
||||
|
|
|
|||
Loading…
Reference in New Issue