|
From: | Germán André Arias Santiago |
Subject: | Re: One question about subclass |
Date: | Wed, 24 Sep 2008 19:27:03 -0700 (PDT) |
I want make an app to solve some physics problems. Then my app have a panel wiht many things (ball, cannon, wall, ....) to represent the problem. When a user do click in some of this things, a NSViewImage is add into the chalckbord (a NSView's subclass). I want let the user to move these things to any position (with a drag operation). But, when I do click in one of this things (NSImageView), the NSView don't get the NSEvent, then I can't move the NSImageView with mouseDragged: method (in the NSView). Even if I add the NSImageView with addSubview: positioned: relativeTo: with the argument NSWindowBelow. I don't know some method to delegate this event from NSImageView to NSView. I tryed with Drag & Drop, but I only can move an image from one NSImageView to another. Then I think in a subclass of NSImageView to write the mouseDragged: method. I add this
subclass in something like this - (void) addObject: (id)sender { /* insert your code here */ NSImage *icono = [[NSImage alloc] initByReferencingFile: @"Resources/112.tif"] ; NSImageView *nuevoIcono = [[MIImagen alloc] initWithFrame: NSMakeRect(20,20,90,90)] ; [nuevoIcono setImage: icono] ; [nuevoIcono setEditable: NO] ; [self addSubview: nuevoIcono positioned: NSWindowBelow relativeTo: self] ; [self setNeedsDisplay: YES] ; RELEASE(icono) ; RELEASE(nuevoIcono) ; } MIImagen is my subclass of NSImageVIew. I add the MIImagen.h file in the header of the chalckboar (NSView's subclass). If I write NSImageView instead MIImagen, the image is added. --- El jue 25-sep-08, Markus Hitter <mah@jump-ing.de> escribió: De: Markus Hitter <mah@jump-ing.de> |
[Prev in Thread] | Current Thread | [Next in Thread] |