10import org.kde.kirigami as Kirigami
53 required property string label
58 property alias maximumLength: textField.maximumLength
63 property alias fieldActiveFocus: textField.activeFocus
68 property alias readOnly: textField.readOnly
78 property alias echoMode: textField.echoMode
90 property alias inputMethodHints: textField.inputMethodHints
99 property alias placeholderText: textField.placeholderText
104 property alias validator: textField.validator
109 property alias acceptableInput: textField.acceptableInput
131 property var status: Kirigami.MessageType.Information
139 property string statusMessage: ""
159 signal editingFinished();
174 function clear(): void {
181 function insert(position: int, text: string): void {
182 textField.insert(position, text);
189 function selectAll(): void {
190 textField.selectAll();
197 function select(start: int, end: int): void {
198 textField.select(start, end);
201 onActiveFocusChanged: {
203 textField.forceActiveFocus();
207 onClicked: textField.forceActiveFocus()
209 Accessible.role: Accessible.EditableText
211 contentItem: ColumnLayout {
212 spacing: Kirigami.Units.smallSpacing
214 spacing: Kirigami.Units.largeSpacing
216 Layout.fillWidth: true
218 elide: Text.ElideRight
219 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
226 text: label(root.maximumLength, root.maximumLength)
227 font: Kirigami.Theme.smallFont
229 function label(current: int, maximum: int): string {
230 return i18ndc("kirigami-addons6
", "@label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
233 // 32767 is the default value for TextField.maximumLength
234 visible: root.maximumLength < 32767
235 text: metrics.label(textField.text.length, root.maximumLength)
236 font: Kirigami.Theme.smallFont
237 color: textField.text.length === root.maximumLength
238 ? Kirigami.Theme.neutralTextColor
239 : Kirigami.Theme.textColor
240 horizontalAlignment: Text.AlignRight
242 Layout.margins: Kirigami.Units.smallSpacing
243 Layout.preferredWidth: metrics.advanceWidth
246 Kirigami.PasswordField {
248 Accessible.description: label
249 Layout.fillWidth: true
250 placeholderText: root.placeholderText
252 onTextChanged: root.text = text
253 onAccepted: root.accepted()
254 onEditingFinished: root.editingFinished()
255 onTextEdited: root.textEdited()
256 activeFocusOnTab: false
259 Kirigami.InlineMessage {
261 visible: root.statusMessage.length > 0
262 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
263 Layout.fillWidth: true
264 text: root.statusMessage
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:50 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.