Kirigami-addons
10import org.kde.kirigami as Kirigami
12import './private' as Private
57 required property string label
62 property alias maximumLength: textField.maximumLength
67 property alias fieldActiveFocus: textField.activeFocus
72 property alias readOnly: textField.readOnly
82 property alias echoMode: textField.echoMode
94 property alias inputMethodHints: textField.inputMethodHints
103 property alias placeholderText: textField.placeholderText
108 property alias validator: textField.validator
113 property alias acceptableInput: textField.acceptableInput
128 property alias cursorPosition: textField.cursorPosition
150 property var status: Kirigami.MessageType.Information
158 property string statusMessage: ""
165 property alias trailing: innerRow.children
185 signal editingFinished();
200 function clear(): void {
207 function insert(position: int, text: string): void {
208 textField.insert(position, text);
215 function selectAll(): void {
216 textField.selectAll();
223 function select(start: int, end: int): void {
224 textField.select(start, end);
227 onActiveFocusChanged: {
229 textField.forceActiveFocus();
233 onClicked: textField.forceActiveFocus()
235 Accessible.role: Accessible.EditableText
237 contentItem: ColumnLayout {
238 spacing: Private.FormCardUnits.verticalSpacing
240 spacing: Private.FormCardUnits.horizontalSpacing
242 Layout.fillWidth: true
245 Layout.fillWidth: true
247 elide: Text.ElideRight
248 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
251 Accessible.ignored: true
256 text: label(root.maximumLength, root.maximumLength)
257 font: Kirigami.Theme.smallFont
259 function label(current: int, maximum: int): string {
260 return i18ndc("kirigami-addons6
", "@
label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
263 // 32767 is the default value for TextField.maximumLength
264 visible: root.maximumLength < 32767
265 text: metrics.label(textField.text.length, root.maximumLength)
266 font: Kirigami.Theme.smallFont
267 color: textField.text.length === root.maximumLength
268 ? Kirigami.Theme.neutralTextColor
269 : Kirigami.Theme.textColor
270 horizontalAlignment: Text.AlignRight
272 Accessible.ignored: !visible
274 Layout.preferredWidth: metrics.advanceWidth
281 spacing: Kirigami.Units.smallSpacing
283 Layout.fillWidth: true
287 Accessible.name: root.label
288 Layout.fillWidth: true
289 placeholderText: root.placeholderText
291 onTextChanged: root.text = text
292 onAccepted: root.accepted()
293 onEditingFinished: root.editingFinished()
294 onTextEdited: root.textEdited()
295 activeFocusOnTab: false
299 Kirigami.InlineMessage {
301 visible: root.statusMessage.length > 0
302 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
303 Layout.fillWidth: true
304 text: root.statusMessage
string label
A label containing primary text that appears above and to the left the text field.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:56:59 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.