Building a Scratch Pad with Cocoa
Subject:   small steps on my own to three color padview
Date:   2001-12-05 21:49:03
From:   mikebeam
Response to: small steps on my own to three color padview

I think your inability to make the return type (void *) comes from the fact that IBAction is actually type void. (void *) is the datatype for a generic pointer, which is something where void is nothing. Weird. Anyway, good stuff.

I enable multiple path support in a version of this little app i wrote a while back by doing exactly what you said with using a mutable array. Basically, it worked by creating a new path and appending it to the mutable array when ever the mouse went down. All mouse drag events appended to the most recently added path in the array. Then in the drawRect method i just enumerated the array, sending a stroke message to each array element. While it would be slow, you could enable color support in this by having each element of this mutable array be an NSDictionary that contains a key-value pair for the path object, and a key-value pair for the color. Thus, in each loop through the enumeration you could set the color to draw in based on the information stored in the dictionary, and then stroke the path. Anyway, have fun!


1 to 2 of 2
  1. NSBezier subclass for ColoredPath
    2001-12-08 23:48:12  psheldon [View]

    • NSBezier subclass creation set with no get accessor
      2001-12-09 07:06:48  psheldon [View]

      • works but with warning (short code eg.)
        2001-12-10 09:24:48  psheldon [View]

        • got rid of warning with accessor and less self
          2001-12-11 10:15:44  psheldon [View]

  2. structs for ColorPath in padview
    2001-12-08 16:02:05  psheldon [View]

1 to 2 of 2