Kirigami-addons
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();
183 function insert(position: int, text: string) {
184 textField.insert(position, text);
187 onActiveFocusChanged: {
189 textField.forceActiveFocus();
193 onClicked: textField.forceActiveFocus()
195 Accessible.role: Accessible.EditableText
197 contentItem: ColumnLayout {
198 spacing: Kirigami.Units.smallSpacing
200 spacing: Kirigami.Units.largeSpacing
202 Layout.fillWidth: true
204 elide: Text.ElideRight
205 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
208 Accessible.ignored: true
213 text: label(root.maximumLength, root.maximumLength)
214 font: Kirigami.Theme.smallFont
216 function label(current: int, maximum: int): string {
217 return i18nc("@label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
220 // 32767 is the default value for TextField.maximumLength
221 visible: root.maximumLength < 32767
222 text: metrics.label(textField.text.length, root.maximumLength)
223 font: Kirigami.Theme.smallFont
224 color: textField.text.length === root.maximumLength
225 ? Kirigami.Theme.neutralTextColor
226 : Kirigami.Theme.textColor
227 horizontalAlignment: Text.AlignRight
229 Layout.margins: Kirigami.Units.smallSpacing
230 Layout.preferredWidth: metrics.advanceWidth
235 Accessible.name: root.label
236 Layout.fillWidth: true
237 placeholderText: root.placeholderText
239 onTextChanged: root.text = text
240 onAccepted: root.accepted()
241 onEditingFinished: root.editingFinished()
242 onTextEdited: root.textEdited()
243 activeFocusOnTab: false
246 Kirigami.InlineMessage {
248 visible: root.statusMessage.length > 0
249 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
250 Layout.fillWidth: true
251 text: root.statusMessage
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:46:57 by
doxygen 1.10.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.