// Copyright © SixtyFPS GmbH // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 import { TextEditBase } from "../common/textedit-base.slint"; import { StyleMetrics } from "std-widgets-impl.slint"; export component TextEdit { in property wrap <=> base.wrap; in property horizontal-alignment <=> base.horizontal-alignment; in property read-only <=> base.read-only; in property font-size <=> base.font-size; in property enabled <=> base.enabled; in property placeholder-text <=> base.placeholder-text; in-out property has-focus: base.has-focus; out property visible-width <=> base.visible-width; out property visible-height <=> base.visible-height; in-out property text <=> base.text; in-out property viewport-x <=> base.viewport-x; in-out property viewport-y <=> base.viewport-y; in-out property viewport-width <=> base.viewport-width; in-out property viewport-height <=> base.viewport-height; callback edited(/* text */ string); accessible-role: AccessibleRole.text-input; accessible-value <=> text; accessible-placeholder-text: text == "" ? placeholder-text : ""; public function set-selection-offsets(start: int,end: int){ base.set-selection-offsets(start, end); } public function select-all(){ base.select-all(); } public function clear-selection(){ base.clear-selection(); } public function cut(){ base.cut(); } public function copy(){ base.copy(); } public function paste(){ base.paste(); } forward-focus: base; horizontal-stretch: 1; vertical-stretch: 1; states [ disabled when !root.enabled: { root.opacity: 0.5; } focused when base.has-focus: { base.border-width: 2px; base.border-color: NativePalette.accent-background; } ] base := TextEditBase { width: 100%; height: 100%; border-radius: 2px; border-width: 1px; border-color: NativePalette.border; scroll-view-padding: 4px; foreground: NativePalette.foreground; placeholder-color: self.enabled ? StyleMetrics.placeholder-color : StyleMetrics.placeholder-color-disabled; selection-background-color: NativePalette.selection-background; selection-foreground-color: NativePalette.selection-foreground; } }