From a73298f978d802ae46eebccdca163fd38131ad79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Thu, 3 Mar 2022 11:59:56 +0100 Subject: [PATCH] fixed apple script to take into account the case where multiple layouts have been added for visual keyboard --- src/frameworks/UBPlatformUtils_mac.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/frameworks/UBPlatformUtils_mac.mm b/src/frameworks/UBPlatformUtils_mac.mm index 7eae208e..3138861f 100644 --- a/src/frameworks/UBPlatformUtils_mac.mm +++ b/src/frameworks/UBPlatformUtils_mac.mm @@ -685,7 +685,16 @@ void UBPlatformUtils::showOSK(bool show) tell application \"System Events\"\n\ tell application process \"TextInputMenuAgent\"\n\ tell menu 1 of menu bar item 1 of menu bar 2\n\ - click menu item 2\n\ + set nbItems to count menu items\n\ + if (nbItems = 4)\n\ + -- only one language so items are\n\ + -- 1. emojis&symbols n-2. keyboard n-1. separator n.preferences\n\ + click menu item (nbItems-2)\n\ + else\n\ + -- items are ... n-4. access keyboard n-3. separator n-2 display names n-1. separator n. preferences\n\ + -- target is in fourth position from bottom\n\ + click menu item (nbItems - 4)\n\ + end if\n\ end tell\n\ end tell\n\ end tell\n\