We have moved to a new Sailfish OS Forum. Please start new discussions there.
0

How to remove all except bottom page from pageStack?

asked 2014-05-29 19:20:06 +0200

kimmoli gravatar image

I have application with few dialogs and subpages, which i push to pageStack when i need them.

Now i have coveractions which also pushes dialog or page to pageStack when invoked.

If user has minimized application with subpage or dialog open, the coveraction will push invoked page on top of these pages, which is the problem.

I solved this to check if pageStack.depth>1, i will replace topmost page with pageStack.Replace(). This however works only if i have only one subpage or dialog open.

I tried to repeat pageStack.pop until pageDepth==1, but the it refuses to open new page as the transition animation is active.

If i use pageStack.pop(pageStack.currentPage, pageStackAction.Immediate) nothing happens.

if i use pageStack.clear, also the "FirstPage" is removed from stack.

Or should i get the component-id of the "FirstPage" and use pageStack.popAttached(firsPageId) ?

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
1

answered 2014-05-29 22:48:27 +0200

Acce gravatar image

updated 2014-05-29 23:10:17 +0200

I see you tried using the pop(page, operationType) with the parameter page, which should work. However, you used pageStack.currentPage as parameter, so it tries to return to the currentpage, therefore doing nothing.

The method find(function) might prove useful, just return true or false from the callback-function depending on if the page is the one you want.

Edit: I went on and tested it, this seems to work properly to get back to the first page:

var wantedPage = pageStack.find(function(page) {
  if(page._depth === 0)
  {
    return true;
  }
  else
  {
    return false;
  }
});
pageStack.pop(wantedPage);
edit flag offensive delete publish link more

Comments

will test soon, tnx.

kimmoli ( 2014-05-29 23:10:03 +0200 )edit

Tests, works fine.

Single-line-of-code;

pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} ), PageStackAction.Immediate)
kimmoli ( 2014-05-30 09:36:02 +0200 )edit
Login/Signup to Answer

Question tools

Follow
1 follower

Stats

Asked: 2014-05-29 19:20:06 +0200

Seen: 360 times

Last updated: May 29 '14