mirror of
https://codeberg.org/vyn/selenite.git
synced 2025-07-03 01:53:18 +00:00
First commit
This commit is contained in:
commit
dd0c8c326a
16 changed files with 534 additions and 0 deletions
47
TextInput.slint
Normal file
47
TextInput.slint
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { VLabeledComponent } from "LabeledComponent.slint";
|
||||
import { Palette } from "Palette.slint";
|
||||
import { VText } from "Text.slint";
|
||||
|
||||
export component VTextInput inherits VLabeledComponent {
|
||||
in-out property text <=> textInputComponent.text;
|
||||
out property has-focus <=> textInputComponent.has-focus;
|
||||
in-out property placeholder <=> textInputComponent.accessible-placeholder-text;
|
||||
in-out property wrap <=> textInputComponent.wrap;
|
||||
callback accepted();
|
||||
callback edited();
|
||||
callback started-writting();
|
||||
|
||||
public function edit-text(text: string) {
|
||||
root.text = text;
|
||||
root.old-text = text;
|
||||
}
|
||||
|
||||
private property <string> old-text: "";
|
||||
|
||||
VerticalLayout {
|
||||
padding: 4px;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
textInputComponent := TextInput {
|
||||
color: Palette.foreground;
|
||||
accepted => { root.accepted() }
|
||||
edited => {
|
||||
root.edited();
|
||||
if (textInputComponent.text != "" && old-text == "") {
|
||||
root.started-writting();
|
||||
}
|
||||
old-text = textInputComponent.text;
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: start;
|
||||
VText {
|
||||
visible: textInputComponent.text == "";
|
||||
color: Palette.foreground-hint;
|
||||
text: root.placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue