Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 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
    Felgo 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.