Answered forward and back buttons for file explorer

sarthemaker

Active member
Joined
Sep 4, 2009
Messages
36
Programming Experience
5-10
I am making a custom file explorer, and I am trying to make back and forward buttons, all I need to happen is when you hit back, it returns the last directory you were in, when you hit forward it returns the directories you were in before hitting back, and when entering a new directory, it erases all of the Forward data. I am not sure how to accomplish this.

If anyone could give me a push in the right direction?
I was thinking of stacks, but no sure how to implement them..
 
Last edited:
If you were to use a stack you'd need two of them: a back stack and a forward stack. When you enter a directory you push its location onto the back stack. When you go back you pop the current location of the back stack and push it onto the forward stack. When you go forward you pop the next location off the forward stack and push it onto the back stack. When you navigate without going back or forward you clear the forward stack.

Just note that your back stack may grow very large.
 
Back
Top