Forums

OverviewV-Play 2 Support (Qt 5) › Prevent dialog from closing

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

    Dauren

    Hello everyone.

    My question is how to prevent a Dialog from closing when android’s back button is pressed. I tried using connectors targeted to the Application and listening for BackButtonPressedGlobally, but no luck. What I want to achieve is a modal dialog box, which cannot be dismissed – either positive or negative action must be chosen.

     

    Cheers.

    #13886

    Günther
    V-Play Team

    Hi Dauren!

    There are currently two ways to show dialogs:
    Either with the QML based InputDialog component, or by using a NativeDialog.

    Unfortunately, both dialogs do not support disabling the back button handling at the moment. When showing a native dialog, the back button button is not handled by QML and always dismisses the dialog. The QML based Dialog handles the back button from within QML, so it would be possible to interrupt this by consuming the back pressed event before the Dialog can handle it.

    Have you tried adding:

          Connections {
            target: getApplication()
            onBackButtonPressedGlobally: {
              console.log("back button pressed")
              event.accepted = true // consume the event so other components, like the dialog don't handle it
            }
          }

    to your QML code?

     

    Best,
    Günther

    #13893

    Dauren

    I’ll give it a shot, and let you know. Thanks, Günther.

    #13897

    Dauren

    So, it does work when

    event.accepted = true

    is specified. Apparently, I missed this bit when I tried for the first time.

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