NSMatrix selectedRow, selectedColumn
NSMatrix selectedRow, selectedColumn
- Subject: NSMatrix selectedRow, selectedColumn
- From: email@hidden
- Date: Sat, 21 Aug 2010 11:19:31 -0600
Below is the implementation of an NSMatrix subclass. What I do not
understand is the NSLog output from -mouseDown.
No matter which cell I click I always get the following, i.e row and
column are always -1.
2010-08-21 11:16:48.705 Customize It[965:813] mouse down
2010-08-21 11:16:48.706 Customize It[965:813] r -1 c -1
What fundamental concept am I missing?
-koko
@implementation FramesMatrix
/* initWithFrame */
- (id) initWithFrame:(NSRect)frameRect {
id aClass = [FramesCell class];
return [super initWithFrame:frameRect mode:NSRadioModeMatrix
cellClass:aClass numberOfRows:1 numberOfColumns:1];
}
- (void)awakeFromNib {
NSSize cellSize;
cellSize.width = cellSize.height = 160;
[self setCellSize:cellSize];
NSSize spacing = NSSizeFromString(@"{8,16}");
[self setIntercellSpacing:spacing];
[self setDrawsBackground:YES];
[self setBackgroundColor:[NSColor whiteColor]];
[self setAutoscroll:YES];
NSScrollView* sv = [self enclosingScrollView];
[sv setDrawsBackground:YES];
[sv setBackgroundColor:[NSColor whiteColor]];
}
- (void)reloadMatrix:(int)itemCnt {
NSScrollView* sv = [self enclosingScrollView];
NSRect svf = [sv frame];
NSRect sr = [self frame];
int cols = sr.size.width / 160;
int rows = (itemCnt / cols) +1;
sr.size.height = (rows * 176);
[self setFrame:sr];
[self renewRows:rows columns:cols];
[self setNeedsDisplay:YES];
}
- (bool)preservesContentDuringLiveResize { return YES; }
- (void)mouseDown:(NSEvent *)theEvent {
NSLog(@"r %d c %d", [self selectedRow], [self selectedColumn]);
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden