NSMatrix disappears
NSMatrix disappears
- Subject: NSMatrix disappears
- From: "Ender Wiggins" <email@hidden>
- Date: Sat, 15 Jul 2006 16:11:50 -0500
I have an NSMatrix of NSButtons and one of NSImageCell's and when I
place them in my NSView and compile my app, I can see them fine (even
though they don't work because the custom class is set to NSMatrix).
But when I set the custom class to a class I subclassed from NSMatrix
and recompile my app, the buttons and cells do not appear in my view,
yet they still work fine if I click in their areas. The images in
either NSMatrix work as my drag source and the drag operation works
fine even though I can't see them.
Any one have any ideas as to why this is? Any help much appreciated.
--- *.m
#import "ToolsPalette.h"
@implementation ToolsPalette
- (id)initWithFrame:(NSRect)frameRect
{
if ((self = [super initWithFrame:frameRect]) != nil) {
}
return self;
}
- (void)drawRect:(NSRect)rect
{ }
- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)event
{
return YES;
}
- (BOOL)ignoreModifierKeysWhileDragging
{
return YES;
}
- (BOOL)acceptsFirstMouse:(NSEvent *)event
{
return YES;
}
- (void)mouseDown:(NSEvent *)event
{
[self setDownEvent:event];
}
- (void)mouseDragged:(NSEvent *)event
{
int row, column = 0;
if ([self getRow:&row column:&column forPoint:[self
convertPoint:[event locationInWindow] fromView:nil]]) {
[self initiateDrag:downEvent];
}
[self setDownEvent:nil];
}
- (NSEvent *)downEvent
{
return downEvent;
}
- (void)setDownEvent:(NSEvent *)event
{
[downEvent autorelease];
downEvent = [event retain];
}
- (void)initiateDrag:(NSEvent *)event
{
int row, column = 0;
NSPasteboard *pb = [NSPasteboard pasteboardWithName: NSDragPboard];
NSImage *dragImage;
NSImage *scaledImage;
NSPoint dragPoint;
NSRect theDraggedCellFrame;
[self getRow:&row column:&column forPoint:
[self convertPoint:[event locationInWindow] fromView:nil]];
scaledImage = [[self cellAtRow:row column:column] image];
theDraggedCellFrame = [self cellFrameAtRow:row column:column];
dragPoint = NSMakePoint(theDraggedCellFrame.origin.x +
([self cellSize].width - [scaledImage size].width) / 2,
theDraggedCellFrame.origin.y +
[scaledImage size].height +
([self cellSize].height - [scaledImage size].height) / 2);
[pb declareTypes: [NSArray arrayWithObjects: NSTIFFPboardType, nil]
owner: self];
[pb setData:[scaledImage TIFFRepresentation] forType:NSTIFFPboardType];
dragImage = [[[NSImage alloc]
initWithSize: [scaledImage size]] autorelease];
[dragImage setName:@"testing"];
[dragImage lockFocus];
[scaledImage dissolveToPoint: NSMakePoint(0,0) fraction: .5];
[dragImage unlockFocus];
[self dragImage: dragImage
at: dragPoint
offset: NSMakeSize(0,0)
event: event
pasteboard: pb
source: self
slideBack: YES];
}
@end
--- *.h
#import <Cocoa/Cocoa.h>
@interface ToolsPalette : NSMatrix
{
@private
NSEvent *downEvent;
}
- (void)drawRect:(NSRect)rect;
- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent;
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
- (BOOL)ignoreModifierKeysWhileDragging;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)event;
- (void)setDownEvent:(NSEvent *)event;
- (NSEvent *)downEvent;
- (void)initiateDrag:(NSEvent *)event;
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden