Mouse Dragging in Apple Sketch

  • Apple provides a sample application called Sketch found in the AppKit
    folder. In the SKTGraphicView.m file there is a single mouse related
    method mouseDown:. There are no mouseDragged:, mouseUp:, or
    mouseMoved: methods.

    My question is how does this application get information on a mouse
    dragged operation? The dragging functionality works but I can not see
    how or where this is implemented in the code.

    Regards, Richard
  • On 20 Oct 2007, at 10:20 PM, Richard Somers wrote:

    > Apple provides a sample application called Sketch found in the
    > AppKit folder. In the SKTGraphicView.m file there is a single mouse
    > related method mouseDown:. There are no mouseDragged:, mouseUp:, or
    > mouseMoved: methods.
    >
    > My question is how does this application get information on a mouse
    > dragged operation? The dragging functionality works but I can not
    > see how or where this is implemented in the code.

    Read the code more carefully.

    Examine the call tree
    mouseDown:
    selectAndTrackMouseWithEvent:
      resizeGraphic:usingHandle:withEvent:
      moveSelectedGraphicsWithEvent:
      marqueeSelectWithEvent:

    In all the methods below mouseDown:, the view goes into a tight loop,
    collecting events until the left mouse button goes up, and responding
    to them. The other mouseXXX: methods are not provided, because
    mouseDown: handles the events in-line.

    This is no longer a recommended way to handle dragging. Provide the
    mouseXXX: methods.

    — F
  • On Oct 21, 2007, at 12:09 AM, Fritz Anderson wrote:

    > Read the code more carefully.
    >
    > Examine the call tree
    > mouseDown:
    > selectAndTrackMouseWithEvent:
    > resizeGraphic:usingHandle:withEvent:
    > moveSelectedGraphicsWithEvent:
    > marqueeSelectWithEvent:
    >
    > In all the methods below mouseDown:, the view goes into a tight
    > loop, collecting events until the left mouse button goes up, and
    > responding to them. The other mouseXXX: methods are not provided,
    > because mouseDown: handles the events in-line.
    >

    The View Programming Guide for Cocoa covers this.

    http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/S
    ubclassingNSView/chapter_5_section_4.html#/

    /apple_ref/doc/uid/TP40002978-CH7-DontLinkElementID_19

    > This is no longer a recommended way to handle dragging. Provide the
    > mouseXXX: methods.

    Actually, both techniques are valid. It depends on the situation. The
    doc covers both cases, and discusses the differences/advantages.
previous month october 2007 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