10import org.kde.kirigami as Kirigami
55 required property string label
60 property alias maximumLength: textField.maximumLength
65 property alias fieldActiveFocus: textField.activeFocus
70 property alias readOnly: textField.readOnly
80 property alias echoMode: textField.echoMode
92 property alias inputMethodHints: textField.inputMethodHints
101 property alias placeholderText: textField.placeholderText
106 property alias validator: textField.validator
111 property alias acceptableInput: textField.acceptableInput
133 property var status: Kirigami.MessageType.Information
141 property string statusMessage: ""
161 signal editingFinished();
176 function clear(): void {
183 function insert(position: int, text: string): void {
184 textField.insert(position, text);
191 function selectAll(): void {
192 textField.selectAll();
199 function select(start: int, end: int): void {
200 textField.select(start, end);
203 onActiveFocusChanged: {
205 textField.forceActiveFocus();
209 onClicked: textField.forceActiveFocus()
211 Accessible.role: Accessible.EditableText
213 contentItem: ColumnLayout {
214 spacing: Kirigami.Units.smallSpacing
216 spacing: Kirigami.Units.largeSpacing
218 Layout.fillWidth: true
220 elide: Text.ElideRight
221 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
224 Accessible.ignored: true
229 text: label(root.maximumLength, root.maximumLength)
230 font: Kirigami.Theme.smallFont
232 function label(current: int, maximum: int): string {
233 return i18nc("@label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
236 // 32767 is the default value for TextField.maximumLength
237 visible: root.maximumLength < 32767
238 text: metrics.label(textField.text.length, root.maximumLength)
239 font: Kirigami.Theme.smallFont
240 color: textField.text.length === root.maximumLength
241 ? Kirigami.Theme.neutralTextColor
242 : Kirigami.Theme.textColor
243 horizontalAlignment: Text.AlignRight
245 Layout.margins: Kirigami.Units.smallSpacing
246 Layout.preferredWidth: metrics.advanceWidth
251 Accessible.name: root.label
252 Layout.fillWidth: true
253 placeholderText: root.placeholderText
255 onTextChanged: root.text = text
256 onAccepted: root.accepted()
257 onEditingFinished: root.editingFinished()
258 onTextEdited: root.textEdited()
259 activeFocusOnTab: false
262 Kirigami.InlineMessage {
264 visible: root.statusMessage.length > 0
265 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
266 Layout.fillWidth: true
267 text: root.statusMessage
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Aug 30 2024 11:47:13 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.