[SailfishDevel] SearchField and focus
Martin Grimme
martin.grimme at gmail.com
Thu Aug 8 16:06:14 UTC 2013
Hi,
I had exactly the same problem. My solution was to define the
SearchField _outside_ the list view, like this:
SilicaListView {
id: listview
...
header: Item {
// This is just a placeholder for the header box. To avoid the
// list view resetting the input box everytime the model resets,
// the search entry is defined outside the list view.
height: headerBox.implicitHeight
}
}
...
Column {
id: headerBox
property int neutralPos: 0
y: 0 - listview.contentY + neutralPos
width: parent.width
Component.onCompleted: {
neutralPos = listview.contentY;
}
SearchField {
...
}
}
That way, the SearchField floats on top of the list at the place
reserved by the placeholder Item.
Martin
2013/8/8, Lucien XU <sfietkonstantin at free.fr>:
> Le jeudi 8 août 2013 17:10:26 Benoît HERVIER a écrit :
>> Hi,
>>
>> I'm trying to use SearchField to have a .... suspense ... a search
>> field for my list view.
>> So i try to filter in realtime ... and i notice that SearchField lose
>> focus
>>
>> Basically, i do a reset on the ListModel and append data
>>
>> This could come from the use i made from SearchField, so here a snippet
>> of the code :
>>
>> SilicaListView {
>> id: notesView
>> model: notesModel
>> anchors.fill: parent
>> header: Column {
>> width: parent.width
>> PageHeader {
>> title: "ownNotes"
>> }
>> SearchField {
>> id: searchField
>> placeholderText: "Search"
>> width: parent.width
>> onTextChanged: {
>> searchText = searchField.text;
>> notesModel.applyFilter(searchText)
>> }
>>
>> }
>> }
>> section {
>> property: 'category'
>> delegate: SectionHeader {
>> text: section
>> }
>> }
>>
>> Any advices ?
>
> I have the same issue. The searchfield got unfocused each time data is added
>
> in a list view. That's not conveinent for an autocomplete field ...
>
> No advices though, I'm trying to see what's wrong.
> _______________________________________________
> SailfishOS.org Devel mailing list
>
More information about the Devel
mailing list