On Tuesday, August 20, 2002, at 02:45 AM, James Farwell wrote:
I want to write a custom view that is somewhat similar to those in
Sketch or OmniGraffle in that the user can manipulate objects in the
view by clicking them, dragging them around, etc. I have looked at the
Sketch example code which is very informative, but I was a little
miffed as to the way the actual event handling was done. In Sketch it
seems that the View catches all the mouse events, and then iterates
through the entire list of "graphics" until it finds one that
intersects with the click. This isn't terribly hard to understand, but
it seems a little tedious, almost like something that one would expect
"for free" with Cocoa. I was hoping to find some sort of interface
sort of like JComponent in Java/Swing whereby I could add an objects to
the view and things such as mouse events would automatically get passed
on to the object itself rather than me having to write my own little
event pump in the View. I was thinking that it might be possible to do
something like this using NSCell, but I'm still sort of new to Cocoa
and a little vague on some of these concepts. Does anybody have any
suggestions, or is the way Sketch does it basically the easiest way?
Thanks!
- James
It would seem to me that it would be beneficial to have the
containing view have this power and not just the objects within said
view. If your sketch objects were sub-classed NSViews I believe that you
could have them handle mouse events by adding them to the responder
chain though. But I don't think it's something that will really be that
useful, selecting more than one object at time is one thing that comes
to mind. Plus it would complicate the role of the view's objects. The
way I was looking at this when I recently did something similar was that
the objects themselves really don't need to know whether or not they are
selected/moved/etc... they should only need to know how to draw
themselves/minipulate how they draw/etc.... I would let their container
handle it's role of object layout, and the objects handle only what
concerns them directly.
Roarke Lynch
-------------------------------
rlynchba(a)earthlink.net
_______________________________________________
cocoa-dev mailing list | cocoa-dev(a)lists.apple.com
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
On Tuesday, August 20, 2002, at 05:36 AM, Arthur VIGAN wrote:
> Hi,
>
> I'd like to know if it is possible to access the RGB values of each
> pixel
> separately in an NSImage?
>
> Thanks in advance.
>
> Arthur
----From the doc's----
NSReadPixel
This function reads a pixel value at the specified location.
NSColor *NSReadPixel(NSPoint passedPoint)
Returns the color of the pixel at the given location. The location
argument is taken in the current coordinate system-in other words, you
must lock focus on the View that contains the pixel that you wish to
query, and then pass the coordinate for the pixel in the View's
coordinate system.
----<Snip>------
I have never used this function before. I would assume that your
NSImage would have to be displayed, unobstructed, in the frontmost
window. But I really don't know. I'm pretty sure that the color you
would be reading off the screen and the color that has been stored in
the image will not match 100% unless the color profile was imbeded in
the image file.
Roarke Lynch
-------------------------------
rlynchba(a)earthlink.net
_______________________________________________
cocoa-dev mailing list | cocoa-dev(a)lists.apple.com
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
On Saturday, August 24, 2002, at 04:15 PM, Onar Vikingstad wrote:
I have a problem with this line of code:
NSArray *arrayOfUser = [[[NSMutableArray alloc] initWithCapacity:2]
arrayWithObjects:[string componentsSeparatedByString:@":"], nil];
[string self] is in this example just dsad:FAFI.F6b3H1OU and when I run
this line, I get:
2002-08-24 22:06:16.639 Apache Protect[1031] *** -[NSCFArray
arrayWithObjects:]: selector not recognized
2002-08-24 22:06:16.654 Apache Protect[1031] *** -[NSCFArray
arrayWithObjects:]: selector not recognized
What is wrong here? Why isn't the array created?
arrayWithObjects is a class method, which you are calling onto a
class instance. You should either be calling [NSArray( or
NSMutableArray) arrayWithObjects:blah, blah, nil] or [[NSArray( or
NSMutableArray) alloc] initWithObjects:blah, blah, nil]. Also, your code
would create an NSMutableArray containing one object, an NSArray. Just
pointing that out.
Roarke Lynch
-------------------------------
rlynchba(a)earthlink.net
_______________________________________________
cocoa-dev mailing list | cocoa-dev(a)lists.apple.com
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.