[SailfishDevel] Use same header item instance in multiple views

Michael Neufing michael at neufing.org
Fri Jul 22 17:43:41 UTC 2016


Hi together!

I am trying to use the same SearchField instance in multiple views as 
header item.
When the page opens, a GridView is displayed with popular content. A 
SearchField is used as header.

When the user focuses and/or writes text into the search field, the page 
should go into "search mode" where the GridView is hidden and a ListView 
with the search results is displayed.
The goal is, that no screen space is wasted while scrolling. Therefore I 
want to have the same SearchField as header on both views.

I tried to add a placeholder item into both views with the same height 
as the SearchField and reparent the SearchField according to the mode 
either into the GridView or the ListView.
While that technically works (scrolling, etc), the SearchField loses 
it's focus during that process and the user has to re-focus the field in 
order to be able to type more text.
Even calling "forceActiveFocus()" or setting "focus = true" on the 
SearchField after the reparenting does not work.

Please see [1] for a code example.

Can anybody help? I want to avoid that the SearchField is always visible 
when scrolling.

Thanks.

Br,
Michael

[1] http://pastebin.com/fhAdELHN


More information about the Devel mailing list