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
135 property var status: Kirigami.MessageType.Information
143 property string statusMessage: ""
163 signal editingFinished();
178 function clear(): void {
185 function insert(position: int, text: string): void {
186 textField.insert(position, text);
193 function selectAll(): void {
194 textField.selectAll();
201 function select(start: int, end: int): void {
202 textField.select(start, end);
205 onActiveFocusChanged: {
207 textField.forceActiveFocus();
211 onClicked: textField.forceActiveFocus()
213 Accessible.role: Accessible.EditableText
215 contentItem: ColumnLayout {
216 spacing: Private.FormCardUnits.verticalSpacing
218 spacing: Private.FormCardUnits.horizontalSpacing
220 Layout.fillWidth: true
223 Layout.fillWidth: true
225 elide: Text.ElideRight
226 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
229 Accessible.ignored: true
234 text: label(root.maximumLength, root.maximumLength)
235 font: Kirigami.Theme.smallFont
237 function label(current: int, maximum: int): string {
238 return i18nc("@label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
241 // 32767 is the default value for TextField.maximumLength
242 visible: root.maximumLength < 32767
243 text: metrics.label(textField.text.length, root.maximumLength)
244 font: Kirigami.Theme.smallFont
245 color: textField.text.length === root.maximumLength
246 ? Kirigami.Theme.neutralTextColor
247 : Kirigami.Theme.textColor
248 horizontalAlignment: Text.AlignRight
250 Accessible.ignored: !visible
252 Layout.preferredWidth: metrics.advanceWidth
257 Accessible.name: root.label
258 Layout.fillWidth: true
259 placeholderText: root.placeholderText
261 onTextChanged: root.text = text
262 onAccepted: root.accepted()
263 onEditingFinished: root.editingFinished()
264 onTextEdited: root.textEdited()
265 activeFocusOnTab: false
268 Kirigami.InlineMessage {
270 visible: root.statusMessage.length > 0
271 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
272 Layout.fillWidth: true
273 text: root.statusMessage
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:45 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.