Forums

OverviewFelgo 2 Support (Qt 5) › Disable specific page .pop() on android back button

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #22340

    Edward

    Hello!

    The first page in my navigation stack is my login page, which then pushes to my homepage.

    I have added a ‘log out’ button to the page, but when users press the back button on android or the navigation.backButton on either platform it logs them out;

    Can I disable these features so that the only way my users can log out is through using the dedicated ‘log out’ button I created?

    Where the homepage is not the first page is my stack I need to be able to target this behaviour to just this page!

     

    Thanks

    Edd

    #22349

    Janne

    If I understood your problem correctly, you could try something like this:

    Page {
    
        onAppeared: mainView.forceActiveFocus()
    
        FocusScope {
            id: mainView
            focus: true
    
            Keys.onBackPressed: {
                // This will grab the back button press
            }
    
    ...
    

    br

    Janne

     

    #22350

    Edward

    Thanks for the response! I’ll test it out tonight and see! Removing the logout signal calls still allowed the page to pop but kept me logged in so efdectiveoy locked me out under ‘already authenticated’

    #22391

    Edward

    Hello Janne!

     

    Thanks again for the help, where I am removing the ‘navigationBar.backButtonItem’ you method disabled this for all pages, meaning I could never navigate back – with a little tweak this works as intended with the code:

     

        FocusScope {
            id: mainView
            focus: true
            Keys.onBackPressed: {
                if(stack.currentPage === homePage) {
    //homePage is the id of the page i do not want to navigate back from
                } else {
                    stack.pop()
    //allows other pages to be popped
                }
    
            }
        }
    
    

     

     

    If there would be a better method than this please let me know 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support