mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-02 01:43:25 +00:00

The function accepts two arguments that specify the start and the end of the text to select. Fixes #4164
70 lines
No EOL
2.2 KiB
Text
70 lines
No EOL
2.2 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
|
|
|
import { LineEditBase} from "../common/lineedit-base.slint";
|
|
import { StyleMetrics } from "std-widgets-impl.slint";
|
|
|
|
export component LineEdit {
|
|
in property <length> font-size <=> inner.font-size;
|
|
in property <string> placeholder-text <=> inner.placeholder-text;
|
|
in property input-type <=> inner.input-type;
|
|
in property horizontal-alignment <=> inner.horizontal-alignment;
|
|
in property read-only <=> inner.read-only;
|
|
in property <bool> enabled: true;
|
|
out property <bool> has-focus <=> inner.has-focus;
|
|
in-out property <string> text <=> inner.text;
|
|
|
|
callback accepted <=> inner.accepted;
|
|
callback edited <=> inner.edited;
|
|
|
|
public function set-selection-offsets(start: int, end: int) {
|
|
inner.set-selection-offsets(start, end);
|
|
}
|
|
|
|
public function select-all() {
|
|
inner.select-all();
|
|
}
|
|
|
|
public function clear-selection() {
|
|
inner.clear-selection();
|
|
}
|
|
|
|
public function cut() {
|
|
inner.cut();
|
|
}
|
|
|
|
public function copy() {
|
|
inner.copy();
|
|
}
|
|
|
|
public function paste() {
|
|
inner.paste();
|
|
}
|
|
|
|
forward-focus: inner;
|
|
horizontal-stretch: 1;
|
|
vertical-stretch: 0;
|
|
min-width: max(160px, layout.min-height);
|
|
min-height: max(32px, layout.min-height);
|
|
|
|
native := NativeLineEdit {
|
|
has-focus <=> root.has-focus;
|
|
enabled: root.enabled;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
layout := HorizontalLayout {
|
|
padding-left: native.native-padding-left;
|
|
padding-right: native.native-padding-right;
|
|
padding-top: native.native-padding-top;
|
|
padding-bottom: native.native-padding-bottom;
|
|
|
|
inner := LineEditBase {
|
|
placeholder-color: self.enabled ? StyleMetrics.placeholder-color : StyleMetrics.placeholder-color-disabled;
|
|
text-color: self.enabled ? StyleMetrics.textedit-text-color : StyleMetrics.textedit-text-color-disabled;
|
|
enabled: root.enabled;
|
|
margin: layout.padding-left + layout.padding-right;
|
|
}
|
|
}
|
|
} |