Add support for calling focus() on TextInput elements

This allows activating text inputs in signal handlers connected for
example to buttons.

This implements parts of #55
This commit is contained in:
Simon Hausmann 2020-09-30 14:35:02 +02:00
parent 6d9af3449a
commit 7e0e7b43f0
9 changed files with 182 additions and 17 deletions

View file

@ -244,6 +244,9 @@ The `TextInput` is a lower-level item that shows text and allows entering text.
within the item
* **`has_focus`** (*bool*): Set to true when item is focused and receives keyboard events.
### Methods
* **`focus()`** Call this function to focus the text input and make it receive future keyboard events.
### Example

View file

@ -574,4 +574,22 @@ App := Window {
label2 := LabeledInput {}
}
}
```
It's also possible to manually activate the focus on elements such as ```TextInput```:
```60
import { Button } from "sixtyfps_widgets.60";
App := Window {
GridLayout {
Button {
text: "press me";
clicked => { input.focus(); }
}
input := TextInput {
text: "I am a text input field";
}
}
}
```