Results 1 to 7 of 7

Thread: Synthetic mouse events got "stuck" at position of firstly generated event

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Synthetic mouse events got "stuck" at position of firstly generated event

    Maybe you need move events?

    Cheers,
    _

  2. #2

    Default Re: Synthetic mouse events got "stuck" at position of firstly generated event

    Thanks for the suggestion. I tried adding move events after each press and release event – to no avail.

    But somehow you could be right. I examined the mouse.x and mouse.y properties for the MouseArea:nPressed(). They are relative to the receiving item. For the synthetic events they also seem to be relative to the first item that was clicked(?). For example:

    qml: PRESSED MouseArea RIGHT: 20::20 <-- simulated press event in the right MouseArea
    qml: PRESSED MouseArea RIGHT: -180::20 <-- simulated press event in the left MouseArea

    In this case all events are received by the right MouseArea as if there is some kind of active focus for mouse events. Subsequently, I examined the MouseArea::entered() and exited() signals which seemed to be send correctly (press event --> onEntered triggered, release event --> onExited triggered).

    Thanks for any clue,
    Thomas
    Last edited by yurumi; 21st August 2015 at 13:23.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Synthetic mouse events got "stuck" at position of firstly generated event

    You can install an event filter on the application object, it will "see" all events that happen in the application.

    Cheers,
    _

  4. #4

    Default Re: Synthetic mouse events got "stuck" at position of firstly generated event

    Thanks for the quick reply! In fact you were so fast that you overtook me while I was editing my previous post (please have a look above).

    In the meantime I installed a custom event filter and compared the real mouse movement events with my generated events. The only differences for the real input are quite alot of MouseMove events and some CursorChange events when the mouse passes the MouseAreas/Rects. I recreated the MouseMove events more sophisticated, so that there is a trail of events from/to the origin before/after each press/release event. I even created CursorChange events everytime the origin is reached. Still doesn't work :-(

    When comparing the real mouse movement with the simulated one, there is another difference: When the simulated move events enter/exit the MouseArea which was previously clicked, onEntered() / onExited() are triggered (not so for the other MouseArea). This also suggests that there is some kind of unreleased focus. I stumbled upon grabMouse() and releaseMouse() for QWidget. The pendant for QQuickItems seems to be ungrabMouse(). I tried creating QEvent::UngrabMouse events which somehow sounds promising. Also no luck

    Maybe it would be better to create QTouchEvent, but this seems to be quite difficult: https://forum.qt.io/topic/46140/gene...ate-touches/12

  5. #5

    Default Re: Synthetic mouse events got "stuck" at position of firstly generated event

    ...just to close this topic: Although not fully satisfying, I figured out a workaround for the above mentioned problem.

    For every MouseArea add:
    Qt Code:
    1. ...
    2. onReleased: {
    3. ...
    4. parent.visible = false
    5. parent.visible = true
    6. }
    To copy to clipboard, switch view to plain text mode 
    so the mouse event somehow gets "reset"...

  6. #6
    Join Date
    Dec 2015
    Posts
    5
    Thanked 1 Time in 1 Post

    Default Re: Synthetic mouse events got "stuck" at position of firstly generated event

    I've found that you can get the item that grabbed the mouse via QQuickWindow::mouseGrabberItem(). Then you have to do the bound checking and call QQuickItem::ungrabMouse() when needed.

    It's probably somehow related to the implementation of dragging.

  7. The following user says thank you to velorums for this useful post:

    anda_skoa (30th December 2015)

Similar Threads

  1. Replies: 3
    Last Post: 7th August 2015, 12:37
  2. Replies: 1
    Last Post: 12th October 2010, 14:43
  3. Replies: 4
    Last Post: 18th April 2010, 00:37
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. Replies: 7
    Last Post: 20th November 2007, 12:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.