Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Catching Escape on a Popup

Catching Escape on a Popup

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 889 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I have a popup window where some settings can be done. Its close policy is set to CloseOnEscape, but if the user made a change, there should be a warning if he wants to apply those changes.

    I wonder how I can achieve this. Using the closePolicy is closing the popup immediately. Using Keys.onEscapePressed does not seem to work, maybe because a popup is not an Item.

    J.HilkJ 1 Reply Last reply
    0
    • M maxwell31

      Hi,

      I have a popup window where some settings can be done. Its close policy is set to CloseOnEscape, but if the user made a change, there should be a warning if he wants to apply those changes.

      I wonder how I can achieve this. Using the closePolicy is closing the popup immediately. Using Keys.onEscapePressed does not seem to work, maybe because a popup is not an Item.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @maxwell31 according to this stack overflow thread

      https://stackoverflow.com/questions/55510064/qml-popup-know-how-it-was-closed/55511670

      esc shortcut should work, can you show, what you tried?


      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
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        Thanks for the Stackoverflow post. I tried

        Shortcut {
            sequence: "Esc"
            onActivated: {
                console.log("Esc: cancel a few things")
                popup.close()
            }
        }
        

        but for some reason it does not get triggered if I hit Esc and I don't get the console message. I will try a minimal (not)working example and post it here

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxwell31
          wrote on last edited by
          #4

          Hm, the problem seems to be that somewhere there is another shortcut with Escape.

            onActivatedAmbiguously: {
                console.log("we love ambiguity")
            }
          

          If I use the above, I get the output.

          1 Reply Last reply
          1

          • Login

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