Forums

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

Viewing 4 posts - 1 through 4 (of 4 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

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