mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
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:
parent
6d9af3449a
commit
7e0e7b43f0
9 changed files with 182 additions and 17 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue