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: ""
178 signal editingFinished();
193 function clear(): void {
200 function insert(position: int, text: string): void {
201 textField.insert(position, text);
208 function selectAll(): void {
209 textField.selectAll();
216 function select(start: int, end: int): void {
217 textField.select(start, end);
220 onActiveFocusChanged: {
222 textField.forceActiveFocus();
226 onClicked: textField.forceActiveFocus()
228 Accessible.role: Accessible.EditableText
230 contentItem: ColumnLayout {
231 spacing: Private.FormCardUnits.verticalSpacing
233 spacing: Private.FormCardUnits.horizontalSpacing
235 Layout.fillWidth: true
238 Layout.fillWidth: true
240 elide: Text.ElideRight
241 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
244 Accessible.ignored: true
249 text: label(root.maximumLength, root.maximumLength)
250 font: Kirigami.Theme.smallFont
252 function label(current: int, maximum: int): string {
253 return i18nc("@label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
256 // 32767 is the default value for TextField.maximumLength
257 visible: root.maximumLength < 32767
258 text: metrics.label(textField.text.length, root.maximumLength)
259 font: Kirigami.Theme.smallFont
260 color: textField.text.length === root.maximumLength
261 ? Kirigami.Theme.neutralTextColor
262 : Kirigami.Theme.textColor
263 horizontalAlignment: Text.AlignRight
265 Accessible.ignored: !visible
267 Layout.preferredWidth: metrics.advanceWidth
272 Accessible.name: root.label
273 Layout.fillWidth: true
274 placeholderText: root.placeholderText
276 onTextChanged: root.text = text
277 onAccepted: root.accepted()
278 onEditingFinished: root.editingFinished()
279 onTextEdited: root.textEdited()
280 activeFocusOnTab: false
283 Kirigami.InlineMessage {
285 visible: root.statusMessage.length > 0
286 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
287 Layout.fillWidth: true
288 text: root.statusMessage
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:12:26 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.