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. WheelHandler not eating events
Forum Updated to NodeBB v4.3 + New Features

WheelHandler not eating events

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 228 Views 1 Watching
  • 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1
    import QtQuick 2.15
    import QtQuick.Window 2.15
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Wheel Handler Issue")
    
        WheelHandler {
            objectName: "handler1"
    
            onWheel: {
                console.log(objectName)
    
                event.accepted = true
            }
        }
    
        WheelHandler {
            objectName: "handler2"
    
            onWheel: {
                console.log(objectName)
    
                event.accepted = true
            }
        }
    }
    

    Output:

    qml: handler2
    qml: handler1
    

    Shouldn't the "event.accepted = true" keep the first wheel handler from firing?

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Okay, feeling a little bit better about this. My test case is something that shouldn't happen anyway:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Wheel Handler Issue")
      
          Item {
              anchors.fill: parent
      
              WheelHandler {
                  objectName: "handler1"
      
                  onWheel: {
                      console.log(objectName)
      
                      event.accepted = true
                  }
              }
          }
      
          Item {
              anchors.fill: parent
      
              WheelHandler {
                  objectName: "handler2"
      
                  onWheel: {
                      console.log(objectName)
      
                      event.accepted = true
                  }
              }
          }
      }
      

      Item precedence solves the need to redefine WheelHandler if needed.
      result:

      qml: handler2
      

      Handler 1 no longer fires. Yay!

      C++ is a perfectly valid school of magic.

      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