Hello, The problem is that when the model changes, the last added delegate steals the focus, as ListView has a focus scope.
If you set "currentIndex: -1" on the ListView, then this behaviour will be disabled. (This is what's done in the SearchPage.qml example in silicacomponentgallery.) cheers, Bea ________________________________________ From: devel-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] on behalf of Martin Grimme [martin.gri...@gmail.com] Sent: 09 August 2013 02:06 To: Lucien XU Cc: devel@lists.sailfishos.org Subject: Re: [SailfishDevel] SearchField and focus 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 <sfietkonstan...@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 > _______________________________________________ SailfishOS.org Devel mailing list _______________________________________________ SailfishOS.org Devel mailing list