LVRS Document Viewer
components/control/InputField.svx
Path: components/control/InputField.svx
InputField
Location: qml/components/control/input/InputField.qml
InputField is the single-line text input built on AbstractInputBar.
Purpose
- Provide compact single-line text entry with optional search mode.
- Include built-in search icon and clear-button behavior.
- Reuse IME safety and focus behavior from shared input base.
- Keep password and read-only usage available through inherited text-input API.
API
Mode constants:
defaultModesearchMode
Mode properties:
modesearchIconVisible(defaults tomode === searchMode)clearButtonVisibleshowClearButton(computed)
Visual customization:
searchIconColor,searchIconStrokeWidthclearIconBackgroundColor,clearIconBackgroundColorDisabledclearIconForegroundColor
Figma-derived defaults:
backgroundColor/backgroundColorFocused/backgroundColorDisabled -> Theme.panelBackground10placeholderColor -> Theme.titleHeaderColorplaceholderColorDisabled -> Theme.disabledColorsearchIconColor -> Theme.descriptionColorclearIconBackgroundColor -> Theme.descriptionColor
Inherited text API (AbstractInputBar):
text,placeholderText,readOnly,validator,maximumLength,inputMethodHints, and others.echoMode(useTextInput.Passwordfor password field)
Usage
import LVRS 1.0 as LV
LV.InputField {
mode: searchMode
placeholderText: "Search"
}
How It Works
- Search icon is painted via
Canvasand repainted on mode/style changes. - Clear button appears only when editable and text is non-empty.
- Clear action empties text and immediately restores input focus.
- Cursor and text selection use default Qt
TextInputbehavior while IME guard remains inherited from base component.
Advanced Example: Validated Input Field
import QtQuick
import LVRS 1.0 as LV
LV.InputField {
placeholderText: "Project ID"
validator: RegularExpressionValidator { regularExpression: /[A-Z0-9_-]{3,20}/ }
onAccepted: console.log("submitted", text)
}
Extended Example: Search / Password / Read-Only
import QtQuick
import LVRS 1.0 as LV
Column {
spacing: 8
LV.InputField {
mode: searchMode
placeholderText: "Search"
}
LV.InputField {
placeholderText: "Password"
echoMode: TextInput.Password
}
LV.InputField {
text: "Read only value"
readOnly: true
}
}
Troubleshooting
If clear button does not appear, verify:
clearButtonVisible == truereadOnly == false- current text length > 0
Recipe: Search Field with Debounced Query
import QtQuick
import LVRS 1.0 as LV
Item {
property string pendingQuery: ""
Timer {
id: debounce
interval: 180
repeat: false
onTriggered: runSearch(pendingQuery)
}
LV.InputField {
mode: searchMode
placeholderText: "Search logs"
onTextEdited: function(value) {
pendingQuery = value
debounce.restart()
}
}
}
Failure Pattern
Using expensive synchronous filtering inside onTextEdited causes keystroke latency.
Debounce or offload heavy work.