-mouseDragged: sent to view when dragging window

  • Hello,

      when I drag my window around by clicking into the toolbar area and drag from
    there, and I do very rapid up-down movements across the entire screen, sometimes
    AppKit - mistakenly - sends a -mouseDragged: to my view situated below the
    toolbar. The call stack looks like this:

    #1    0x0000000103617e99 in -[SomeView mouseDragged:] at /SomeView.m:209
    #2    0x00007fff8c9b070d in -[NSObject performSelector:withObject:] ()
    #3    0x00007fff97d7cf6a in forwardMethod ()
    #4    0x00007fff8c9b070d in -[NSObject performSelector:withObject:] ()
    #5    0x00007fff97d7cf6a in forwardMethod ()
    #6    0x00007fff8c9b070d in -[NSObject performSelector:withObject:] ()
    #7    0x00007fff97d7cf6a in forwardMethod ()
    #8    0x00007fff8c9b070d in -[NSObject performSelector:withObject:] ()
    #9    0x00007fff97d7cf6a in forwardMethod ()
    #10    0x00007fff97d777ac in -[NSWindow sendEvent:] ()
    #11    0x00007fff97d10a55 in -[NSApplication sendEvent:] ()
    #12    0x00007fff97ca70c6 in -[NSApplication run] ()
    #13    0x00007fff97f23244 in NSApplicationMain ()
    #14    0x0000000103401412 in main at /Users/markus/Projects/rubiTrack/src/main.m:20
    #15    0x00000001033f8324 in start ()

    When I drag the window title area (not the toolbar ) using the same kind of
    movement, this doesn't happen.

    Can someone confirm this? My view reacts to -mouseDragged: but doesn't check if
    there's been a -mouseDown: first because that's implicit. Did that change?

    Regards
    Markus
    --
    __________________________________________
    Markus Spoettl
  • On Jul 24, 2012, at 13:36 , Markus Spoettl wrote:

    > My view reacts to -mouseDragged: but doesn't check if there's been a -mouseDown: first because that's implicit. Did that change?

    The Cocoa Event Handling Guide says "Mouse events are dispatched by an NSWindow object to the NSView object over which the event occurred", so I guess there's a lag/race condition that's putting your view under the mouse pointer at the moment the event is generated.

    I think it's implicit that a mouseDown has occurred before a mouseDragged, but I don't see anything that guarantees they're sent to the same view. In that case, you should really set a state flag in mouseDown that's checked in mouseDragged.
  • On 7/24/12 11:29 PM, Quincey Morris wrote:
    >> My view reacts to -mouseDragged: but doesn't check if there's been a
    >> -mouseDown: first because that's implicit. Did that change?
    >
    > The Cocoa Event Handling Guide says "Mouse events are dispatched by
    > an NSWindow object to the NSView object over which the event occurred", so I
    > guess there's a lag/race condition that's putting your view under the mouse
    > pointer at the moment the event is generated.

    It also states (a few times in different wording):

    >>>>>
    For each dragging sequence, the Application Kit sends a mouseDown: message to a
    responder object, then sends one or more mouseDragged: messages, and ends the
    sequence with a mouseUp: message.
    <<<<<

    While it doesn't spell it out, it's pretty clear they're talking about the same
    view/responder for all those events.

    > I think it's implicit that a mouseDown has occurred before a mouseDragged, but I
    > don't see anything that guarantees they're sent to the same view. In that case,
    > you should really set a state flag in mouseDown that's checked in mouseDragged.

    When I click into a view and drag, it gets all dragging events, even if the
    cursor is dragged outside its frame. Also, views over which the cursor is
    dragged during this process, don't get a single -mouseDragged: message.

    I don't believe that getting -mouseDragged: without a prior -mouseDown: or
    following -mouseUp: is intentional.

    Regards
    Markus
    --
    __________________________________________
    Markus Spoettl
  • On 25/07/2012, at 5:19 PM, Markus Spoettl wrote:

    > I don't believe that getting -mouseDragged: without a prior -mouseDown: or following -mouseUp: is intentional.

    I tend to agree, but I have also observed the issue you're having as well.

    Basically, if you didn't get a mouseDown:, you should ignore any mouseDragged: events. It seems there are situations where the mouseDragged gets dispatched erroneously.

    --Graham
previous month july 2012 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today