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. MouseArea doesn't emit clicked after pressed/released pair

MouseArea doesn't emit clicked after pressed/released pair

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 873 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.
  • SebastianMS Offline
    SebastianMS Offline
    SebastianM
    wrote on last edited by SebastianM
    #1

    Hi,
    I'm experimenting with Wayland Compositor under Qt 5.14.1 on Embedded system with touch screen. I'm forwarding TouchEvents to one of two applications with

            surface()->compositor()->defaultSeat()->sendTouchPointEvent(surface(), id, point, state);
    

    It works. But I noticed that - from time to time - one of buttons in 4 buttons row in one of applications doesn't response, not the same.
    After adding handler to all possible signals - I've noticed that from time to time - pressed and released signals are emitted, but not clicked.
    From qtdeclarative/src/quick/items/qquickmousearea.cpp and setPressed function analysis it looks like to emit clicked if (isclick && !d->longPress && !d->doubleClick){
    As I sad - all handlers are logging, so I'm sure that no PressAndHold and DoubleClick are emitted.
    What remains is content of isclick bool flag - bool isclick = wasPressed && p == false && dragged == false && d->hovered == true;
    I'm sure that wasPressed is true and p is false (otherwise there wouldn't be pressed and released signals).
    MouseEvent contains most of above mentioned parameters. isClick is false for Released events. Also hovered/containsMouse is false. Which is crazy, as hoverEnabled by default is false so hovered should be registered only on click.

    Due to size of code and amount of applications and their interactions - it's very difficult to produce minimal reproduction set.

    I'm in pickle. How to explain lack of clicked signal? How to modify MouseArea to be sure that this signal is emitted (like block drag - which AFAIR is by default inactivate).

    1 Reply Last reply
    0
    • SebastianMS Offline
      SebastianMS Offline
      SebastianM
      wrote on last edited by
      #2

      I've narrow the root cause. Between TouchBegin and TouchEnd send from touch screen there's strange MouseMove event (it doesn't show always). When I move finger on screen - there's plenty of TouchUpdate events which are then translated to MouseMove.
      Yet, this single MouseMove right after TouchBegin has no TouchUpdate.
      I logged source of event - for all MousePressed and MouseRelesed it's Qt::MouseEventSynthesizedByQt which is result of translating TouchBegin/TouchEnd/TouchUpdate to their Mouse equivalent.
      This single MouseMove which makes so much problem has source Qt::MouseEventNotSynthesized. Which puzzles me a lot - as this means that event is received from Mouse device. Whole system is embedded, there's no Mouse device.
      Furthermore - TouchBegin and TouchEnd has the same coordinates, but this MouseMove usually has coordinates (10+, 10+) bigger then original.
      Right now I'm investigating Qt code for locations where QMouseEvent with MouseMove type could be generated.
      There's no way to identify who's event sender by recipient.

      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        Mouse Events and Touch Event Synthesizing

        QTouchEvent delivery is independent from that of QMouseEvent. The application flags Qt::AA_SynthesizeTouchForUnhandledMouseEvents and Qt::AA_SynthesizeMouseForUnhandledTouchEvents can be used to enable or disable automatic synthesizing of touch events to mouse events and mouse events to touch events.

        https://doc.qt.io/qt-5/qtouchevent.html

        Can you try these flags? I am using Qt 5.15.2 and had issues(no response of buttons) on touch screen as well.

        1 Reply Last reply
        0
        • SebastianMS Offline
          SebastianMS Offline
          SebastianM
          wrote on last edited by SebastianM
          #4

          System uses Wayland. For UI design reasons there're decision to move touch area (-12,-15) in reference to display area.
          And ... from time to time Wayland provides Touch Event not translated. Which - by Qt internals - is recognized as moved.
          As a solution I added evenFilter to problematic buttons with

             bool eventFilter(QObject *obj, QEvent *event) override                                                                                                                  
             {                                                                                                                                                                       
                 if (event->type() == QEvent::MouseMove)                                                                                                                             
                 {                                                                                                                                                                   
                     QMouseEvent *ev = dynamic_cast<QMouseEvent*>(event);                                                                                                            
                     auto * quickItem = qobject_cast<QQuickItem*>(obj);                                                                                                              
                     if (quickItem && !quickItem->contains(ev->pos()) && ev->source() == Qt::MouseEventNotSynthesized && !ev->spontaneous())                                         
                     {                                                                                                                                                               
                         return true;                                                                                                                                                
                     }                                                                                                                                                               
                 }                                                                                                                                                                   
                 return QObject::eventFilter(obj, event);                                                                                                                            
             }   
          

          I could strengthen condition by adding test for touch point translation (like pos diff == (12,15)), but above solution works good enough.
          Still, it's workaround.

          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