mirror of https://github.com/mum4k/termdash.git
Updated Widget API (markdown)
parent
172fce3902
commit
1657bc6e70
|
@ -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. **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.
|
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
|
### 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.
|
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.
|
||||||
|
|
Loading…
Reference in New Issue