You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xpf/platforms/macos.md
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ However there are problems with this mapping:
17
17
2.`ModifierKeys.Windows` is actually [not set in `Keyboard.Modifiers` in WPF](https://github.com/dotnet/wpf/blob/6634719e22053aab8e5e0db37618170494aea334/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/KeyboardDevice.cs#L207-L219)
18
18
3. Common controls such as text boxes are expected to have different keyboard shortcuts in macOS, such as "Move the insertion point to the beginning of the previous word" being Option+Left Arrow on macOS instead of Control+Left Arrow
19
19
20
-
## Automatic macOS Key Mapping
20
+
###Automatic macOS Key Mapping
21
21
22
22
To fix many of these problems, one can call the `XpfKeyboard.MapMacOSKeys()` method on startup. This would usually be done in the same place as [the XPF WinAPI shim setup](../third-party-libraries); that is, in the constructor of your `App` class or `Program.Main`:
23
23
@@ -45,6 +45,27 @@ Calling this method on macOS:
45
45
- Option+Left Arrow-> Ctrl+Left Arrow
46
46
- Option+Left Arrow -> Ctrl+Left Arrow
47
47
48
-
##Automatic macOS Keyboard Mapping
48
+
### macOS Custom Keyboard Mapping
49
49
50
-
For more flexible key mapping you can [add custom key mappings](../advanced/key-mapping).
50
+
For more flexible key mapping you can [add custom key mappings](../advanced/key-mapping).
51
+
52
+
## Context Menus <MinVersionversion="1.6" />
53
+
54
+
On macOS, context menus can be opened by Ctrl+Clicking as well as by right clicking. You can enable this feature by setting `XpfMouse.ShowContextMenuOnMacOSCtrlClick` on startup. This would usually be done in the same place as [the XPF WinAPI shim setup](../third-party-libraries); that is, in the constructor of your `App` class or `Program.Main`:
55
+
56
+
```csharp
57
+
usingSystem.Windows;
58
+
usingAtlantis;
59
+
60
+
namespaceXpfKeyboardMappingExample;
61
+
62
+
publicpartialclassApp : Application
63
+
{
64
+
publicApp()
65
+
{
66
+
XpfMouse.ShowContextMenuOnMacOSCtrlClick=true;
67
+
}
68
+
}
69
+
```
70
+
71
+
Once this feature is enabled, it can be disabled on a per-control basis by handling the [`ContextMenuOpening` event](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/how-to-handle-the-contextmenuopening-event#suppressing-any-existing-context-menu-and-displaying-no-context-menu) and checking the value of [`Keyboard.Modifiers`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.input.keyboard.modifiers) and/or [`Mouse.LeftButton`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.input.mouse.leftbutton) to determine how the context menu is being opened.
0 commit comments