Updated Widget API (markdown)

Jakub Sobon 2020-11-28 00:33:32 -05:00
parent 172fce3902
commit 1657bc6e70
1 changed files with 13 additions and 0 deletions

@ -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.