Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › how to catch android back button in App

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18221

    Marek

    Hi

    How to catch android back button in application?

    With ApplicationWindow I have onClosing signal

    With VPlay Games there is onBackButtonPressed

    But how about VPlayApps ? I have tried this code but it seems no key events are received inside Page or Rectangle

    
                focus:true
                Keys.enabled: true
                Keys.onPressed:{
                    console.debug("back key")
                }
                Keys.onReleased: {
                    console.log("back key")
                }
                Keys.onBackPressed: {
                    console.log("back key")
                }

    Particulary with Page and “backNavigationEnabled: false” which is good when user is already logged in (can’t go back to login page), but then I can’t close the app

    Best Regards

    Marek

    #18222

    Marek

    ok part of the problem is solved.

    When I set navigationBar.backButtonVisible:false inside NavigationStack (instead of backNavigationEnabled: false in loggedPage) the effect is the same – user cannot go back from loggedPage to loginPage but android back key is closing the app, but still how to catch onClosing or something similar to display close dialog ?

     

    Best Regards

    Marek

    #18246

    Günther
    Felgo Team

    Hi,

    The App type also supports a signal onBackButtonPressed, which you can use (it’s missing in the docs/auto-completion, as we intend to improve custom back button handling within Felgo Apps in the future):

    App {
      onBackButtonPressedGlobally: {
        event.accepted = true
    
        // do sth here
        console.log("BACK PRESSED")
      }
    }

    Best,
    Günther

    #18270

    Marek

    Hi

    Yeah, it works!

    onBackButtonPressedGlobally: {
            if(mainNavigation.currentIndex==0) {
                event.accepted = true
                console.log("BACK PRESSED")
                Qt.quit()
            } else {
                event.accepted=false
            }
    }

    Best Regards

    Marek

    #24491

    Paweł

    Any improvements about custom back button handling? Is there a possibility to handle back button in Page component, not globally?

    #24492

    Alex
    Felgo Team

    Hi Pawel,

    we will introduce improvements to the back button handling with the next update. This will allow you to e.g. stop a specific page from popping and instead handle the back button event yourself inside this page.

    Best,
    Alex

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

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded