diff --git a/Widget-API.md b/Widget-API.md index 5fa6c05..607ece0 100644 --- a/Widget-API.md +++ b/Widget-API.md @@ -78,6 +78,19 @@ This type is used by the widget to specify the scope at which it wants to receiv 1. **KeyScopeFocused** indicates that the widget wants to receive keyboard events when its container is focused. See [[Keyboard focus|keyboard-focus]] for more details. 1. **KeyScopeGlobal** indicates that the widget wants to receive all keyboard events, even if its container isn't focused. +#### Receiving keyboard events exclusively + +Without other configuration, keyboard events can be delivered to multiple widgets, e.g. a widget that registered for **KeyScopeFocused** and is currently focused and all other widgets that registered for **KeyScopeGlobal**. A widget can request to receive keyboard events exclusively while focused by specifying the **ExclusiveKeyboardOnFocus**: + +```go +Options{ + WantKeyboard: KeyScopeFocused, + ExclusiveKeyboardOnFocus: true, +} +``` + +This can be useful for widgets like the `textinput` which don't want to trigger keyboard shortcuts of other widgets when the user is typing text. + ### Mouse events Widgets can choose whether they want to subscribe to mouse events. Unless this is specifically requested, the widget won't receive any mouse events, so its **widgetapi.Mouse** method won't be called.