Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Trouble with back-button an android

Trouble with back-button an android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
24 Posts 2 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Vega4

    @J-Hilk
    Seems like we want the application to actually close. Like we want the opposite. Minimize or anything or to have control over the process but like described above. for anything we do we are unable to intercept the key_back event.

    That's what we want - to intercept the key-back event since we need to do some cleaning up before sending the app to the back.

    There must be some reason for which the app is completely unaware of the back-keyt presses which is why.. it is not minimized in the first place (which should be by default right?) maybe because it's full-screen? maybe because of some of the flags? we've got no idea but the problem is here.

    J.HilkJ Online
    J.HilkJ Online
    J.Hilk
    Moderators
    wrote on last edited by J.Hilk
    #13

    @Vega4 said in Trouble with back-button an android:

    @J-Hilk
    Seems like we want the application to actually close. Like we want the opposite. Minimize or anything or to have control over the process but like described above. for anything we do we are unable to intercept the key_back event.

    That's what we want - to intercept the key-back event since we need to do some cleaning up before sending the app to the back.

    There must be some reason for which the app is completely unaware of the back-keyt presses which is why.. it is not minimized in the first place (which should be by default right?) maybe because it's full-screen? maybe because of some of the flags? we've got no idea but the problem is here.

    now I get it :D

    maybe because it's full-screen? maybe because of some of the flags

    very possible, yes! You could reduce the flags/remove them and add one after the other to see if the event comes through?

    Have you checked Shortcuts ? From my experience, they are triggered reliably

    Shortcut {
            sequence: StandardKey.Back
            onActivated: console.log("back Key")
        }
    Shortcut {
            sequence: StandardKey.Quitt
            onActivated: console.log("Quit Key")
        }
    Shortcut {
            sequence: StandardKey.Close
            onActivated: console.log("Close Key")
        }
    

    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    V 2 Replies Last reply
    0
    • J.HilkJ J.Hilk

      @Vega4 said in Trouble with back-button an android:

      @J-Hilk
      Seems like we want the application to actually close. Like we want the opposite. Minimize or anything or to have control over the process but like described above. for anything we do we are unable to intercept the key_back event.

      That's what we want - to intercept the key-back event since we need to do some cleaning up before sending the app to the back.

      There must be some reason for which the app is completely unaware of the back-keyt presses which is why.. it is not minimized in the first place (which should be by default right?) maybe because it's full-screen? maybe because of some of the flags? we've got no idea but the problem is here.

      now I get it :D

      maybe because it's full-screen? maybe because of some of the flags

      very possible, yes! You could reduce the flags/remove them and add one after the other to see if the event comes through?

      Have you checked Shortcuts ? From my experience, they are triggered reliably

      Shortcut {
              sequence: StandardKey.Back
              onActivated: console.log("back Key")
          }
      Shortcut {
              sequence: StandardKey.Quitt
              onActivated: console.log("Quit Key")
          }
      Shortcut {
              sequence: StandardKey.Close
              onActivated: console.log("Close Key")
          }
      
      V Offline
      V Offline
      Vega4
      wrote on last edited by
      #14

      @J-Hilk said in Trouble with back-button an android:

      very possible, yes! You could reduce the flags/remove them and add one after the other to see if the event comes through?

      actually I'm right at it this very moment;d it's cooking...

      1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @Vega4 said in Trouble with back-button an android:

        @J-Hilk
        Seems like we want the application to actually close. Like we want the opposite. Minimize or anything or to have control over the process but like described above. for anything we do we are unable to intercept the key_back event.

        That's what we want - to intercept the key-back event since we need to do some cleaning up before sending the app to the back.

        There must be some reason for which the app is completely unaware of the back-keyt presses which is why.. it is not minimized in the first place (which should be by default right?) maybe because it's full-screen? maybe because of some of the flags? we've got no idea but the problem is here.

        now I get it :D

        maybe because it's full-screen? maybe because of some of the flags

        very possible, yes! You could reduce the flags/remove them and add one after the other to see if the event comes through?

        Have you checked Shortcuts ? From my experience, they are triggered reliably

        Shortcut {
                sequence: StandardKey.Back
                onActivated: console.log("back Key")
            }
        Shortcut {
                sequence: StandardKey.Quitt
                onActivated: console.log("Quit Key")
            }
        Shortcut {
                sequence: StandardKey.Close
                onActivated: console.log("Close Key")
            }
        
        V Offline
        V Offline
        Vega4
        wrote on last edited by Vega4
        #15

        @J-Hilk said in Trouble with back-button an android:

        very possible, yes! You could reduce the flags/remove them and add one after the other to see if the event comes through?

        It's confirmed.. the flags. Now how about it, we like need them :-)

        J.HilkJ 1 Reply Last reply
        1
        • V Offline
          V Offline
          Vega4
          wrote on last edited by
          #16

          At this very moment focusing in on the specific culprit flag which prevents the key-events from being dispatched.

          1 Reply Last reply
          0
          • V Vega4

            @J-Hilk said in Trouble with back-button an android:

            very possible, yes! You could reduce the flags/remove them and add one after the other to see if the event comes through?

            It's confirmed.. the flags. Now how about it, we like need them :-)

            J.HilkJ Online
            J.HilkJ Online
            J.Hilk
            Moderators
            wrote on last edited by
            #17

            @Vega4 I'm out of my depth here, especially as that is probably also all dependent on the window manager you/your OS uses :(


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            V 1 Reply Last reply
            0
            • V Offline
              V Offline
              Vega4
              wrote on last edited by
              #18

              Happens on all recent Samsung/ HTC/Huawei devices we've got at hand :-)

              1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @Vega4 I'm out of my depth here, especially as that is probably also all dependent on the window manager you/your OS uses :(

                V Offline
                V Offline
                Vega4
                wrote on last edited by Vega4
                #19

                @J-Hilk

                We've pretty much closed-in onto the problem. No key-events regarding the bottom navigation bar are dispatched and processed at all once any of the following flags are set (in conjunction or individually):

                • Qt.WA_TranslucentBackground
                • Qt.WindowTitleHint
                • (~Qt.WA_ContentsMarginsRespectsSafeArea)

                We need these flags, and it happens when ANY of the above are set.

                Setting visibility: Window.FullScreen doesn't seem to affect anything BUT the app looks simply ugly without the above flags. (huge empty black bars on top and bottom.. also yeah due to missing support for smart-borders on android with devices with rounded screens we had to do that by hand).

                Time to file a bug-report?

                J.HilkJ 1 Reply Last reply
                0
                • V Vega4

                  @J-Hilk

                  We've pretty much closed-in onto the problem. No key-events regarding the bottom navigation bar are dispatched and processed at all once any of the following flags are set (in conjunction or individually):

                  • Qt.WA_TranslucentBackground
                  • Qt.WindowTitleHint
                  • (~Qt.WA_ContentsMarginsRespectsSafeArea)

                  We need these flags, and it happens when ANY of the above are set.

                  Setting visibility: Window.FullScreen doesn't seem to affect anything BUT the app looks simply ugly without the above flags. (huge empty black bars on top and bottom.. also yeah due to missing support for smart-borders on android with devices with rounded screens we had to do that by hand).

                  Time to file a bug-report?

                  J.HilkJ Online
                  J.HilkJ Online
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #20

                  @Vega4 said in Trouble with back-button an android:

                  Time to file a bug-report?

                  possibly,
                  you should get at least a "good" answer ;)

                  Don't forget to post a link here, so others can follow the report as well


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  V 1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    Vega4
                    wrote on last edited by
                    #21

                    @J-Hilk kindly thank you for your prompt responses. You've been dancing with the Wizards🧙🦹‍♀️ (https://twitter.com/gridnetproject it's been all recorded LIVE on YouTube).

                    Will do 🙏

                    1 Reply Last reply
                    0
                    • J.HilkJ J.Hilk

                      @Vega4 said in Trouble with back-button an android:

                      Time to file a bug-report?

                      possibly,
                      you should get at least a "good" answer ;)

                      Don't forget to post a link here, so others can follow the report as well

                      V Offline
                      V Offline
                      Vega4
                      wrote on last edited by
                      #22

                      @J-Hilk Just noticed it's you who were the one who helped us with the custom full-screen support on android back in May https://twitter.com/gridnetproject/status/1389222481874014209... thank you yet again!

                      J.HilkJ 1 Reply Last reply
                      1
                      • V Vega4

                        @J-Hilk Just noticed it's you who were the one who helped us with the custom full-screen support on android back in May https://twitter.com/gridnetproject/status/1389222481874014209... thank you yet again!

                        J.HilkJ Online
                        J.HilkJ Online
                        J.Hilk
                        Moderators
                        wrote on last edited by
                        #23

                        @Vega4 said in Trouble with back-button an android:

                        @J-Hilk Just noticed it's you who were the one who helped us with the custom full-screen support on android back in May https://twitter.com/gridnetproject/status/1389222481874014209... thank you yet again!

                        You're welcome :D
                        it helps me too, as I'm currently stuck in my own project, and changing the train of thought can help in those cases.


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          Vega4
                          wrote on last edited by Vega4
                          #24

                          Update: Seeing that system-menu related events work in presence of these flags when a QDialog gets opened we hoped that enforcing focus onto the main window once the Main window component gets rendered would help. We've wrapped everything around FocusScope and used forceActiveFocus() within Component.onCompleted(). but this didn't help either. Shortcuts do not get triggered as well.

                          Link to bug-report:here

                          It is a pitty I do not have QT's Source available since in assembly I can see that QGuiApplicationPrivate:processKeyEvent DOES process the event when back button is pressed at all times.

                          Seems like to get around this we would need to make a custom QT build one messing around with QGuiApplicationPrivate:processKeyEvent(), which by the way has lots of customized processing related to android's back_button just from the first looks on it. Can't override it (static method.. and obviously exotic stuff like https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern aren't here at play , by design, of course ;d).

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved