Why is NSCollectionViews drawRect called first instead of subview (isOpaque:YES) bug?
Hey guys, I have a serious problem with the CollectionView and I don’t understand its behavior. My Project has a Splitview into 2 Views, one is a Scrollview with a CollectionView the one is a normal NSView with background image. The other one with the CollectionView has multiple items with own Views. The view of the item and the other „static“ NSView with background image have a subview of MeteringView of the MatrixMixerTest example project from Apple. This Metering View is showing Audio levels passed through it in a Meter. The View has isOpaque:Yes. The problem now is, those Meteringviews get redrawn with a timer to represent the Audio Levels but MeteringView is quite efficient to just draw the difference area what changed. In the „static“ NSView with background this works fine because isOpaque of MeteringView is preventing drawRect of the static View to draw again its background image to draw again, because if it does the meter is gone and just the currently changing parts are getting drawn. The CollectionView works differently, there the drawRect of the Item gets somehow called first causes its background color to redraw hiding my meter. But why does it? MeteringView is added in the same way as a subview and setNeedsDisplay is called in MeteringView to redraw metering view and isOpaque to prevent the „parent“ Views to redraw. I don’t know how to solve this, any ideas? I don’t think this is a bug but I don’t know why drawRect of the CollectionView Item is called in the first place. Thanks - Benjamin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSCollectionView item crashes when bound
Hey guys I'm really grinding with the NSCollectionView when its bound. I had a running collection view but wanted to use bindings, I looks like it should work, but it doesn't. This is written just in code not in IB. Hope you guys can help :) The problem is, the View is displayed correctly, but as soon as I try to bind a property in the newItemForRepresentedObject method, it is trying to call setChannelID (I can see it in the console outputting "hello" all the time, but keeps stuck in the else part of the if statement. It never gets to make the if true, always trying to set it. There is no output after the self.channelID = chanID; command, there is just another hello. I think the ChannelView property is not holding the data. The program crashes after 10 seconds trying to set the value. It should be possible to do this, others have obviously bound in the newItemForRepresentedObject. Anyway, any help is appreciated this is the code: ChannelView #import @interface ChannelView : NSView @property (readwrite, nonatomic, copy) NSString *channelName; @property (readwrite, nonatomic, copy) NSNumber *channelID; @property (readwrite) NSTextField *channelNameField; @property (readwrite) NSTextField *deviceChannelField; @end @implementation ChannelView - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:NSMakeRect(0, 0, 300, 500)]; if (self) { // Initialization code here. ColorView *test = [[ColorView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; self.channelNameField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)]; self.deviceChannelField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 50, 100, 20)]; [self addSubview:test]; [self addSubview:self.channelNameField]; [self addSubview:self.deviceChannelField]; } return self; } -(id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; //add die teile return self; } - (void)drawRect:(NSRect)dirtyRect { // Drawing code here. } // setters. -(void)setChannelID:(NSNumber *)chanID { //NSLog(@"hallo"); if (self.channelID == chanID) { return; NSLog(@"da"); } else { NSLog(@"hello"); //just this in debug output //self.channelID = [chanID copy]; NSLog(@"no output"); self.channelID = chanID; NSLog(@"chanid %d current: %d", chanID.intValue, self.channelID.intValue); //never shown in debug [self.deviceChannelField setStringValue:[NSString stringWithFormat:@"%d",self.channelID.intValue]]; } } @end The piece of my subclassed NSCollectionView - (NSCollectionViewItem *)newItemForRepresentedObject:(ChannelsToMixes*)object { NSCollectionViewItem *item = [super newItemForRepresentedObject:object]; // ChannelView *view = (ChannelView *)[item view]; NSLog(@"cahnnelid: %d",object.channelID.intValue); // [view bind:@"title" toObject:object withKeyPath:@"title" options:nil]; [item.view bind:@"channelID" toObject:object withKeyPath:@"channelID" options:nil]; //NSLog(@"test"); //NSLog(@"%@",object); return item; } self.collectionView = [[ChannelCollectionView alloc] initWithFrame:NSMakeRect(10, 0, width, self.splitview.frame.size.height)]; [self.collectionView setItemPrototype:[ChannelViewItemController new]]; [self.collectionView setMaxNumberOfRows:1]; [self.collectionView setAutoresizingMask:(NSViewMinXMargin | NSViewWidthSizable | NSViewMaxXMargin | NSViewMinYMargin | NSViewHeightSizable| NSViewMaxYMargin)]; [self.collectionView setAutoresizesSubviews:YES]; [self.collectionView bind:NSContentBinding toObject:self.channelController withKeyPath:@"arrangedObjects" options:nil]; ChannelViewItemController: @implementation ChannelViewItemController -(void)loadView { [self setView:[[ChannelView alloc] initWithFrame:NSZeroRect]]; } @end The actual value is passed to the setter method, but just not held by the property I think, but why? Tried multiple properties, strong, readwrite atomic or nonatmoic but thats not helping. What is the thing to get the NSCollectionView set up with bindings? Thanks Benjamin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Arraycontroller and CoreData
Hey guys, I'm really confused with the array controller and core data. I don't know what I have to use to get what I want. My program has for now a CollectionView which is populated by a core data fetch request. If I use an arrayController, I don't have to make this fetch do I? I can tell the array controller to fetch: ? Next thing is, when new Items are added to the collection view, it should automatically change. A binding of the collection view is enough? Something like [collectionview bind: toObject:….] And, for now I add data to my core data database with insertNewObjectForEntityForName. Is that okay or should I add it with the array controller's add oder insertObject methods? The new entries have to keep their relationships and I don't know how I can define them with the array controller methods. Thanks in advance! Benjamin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
scrollPoint in NSScrollView does not scroll
Hey, I'm trying this for I think over 3 hours just to get my View to scroll to a point when loaded. But not to start and cut off the rest of it, just be scrolled to there. Tried it in my real project, didn't work, made small test project, doesn't work either. NSScrollView* myscrollview = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)]; NSClipView* myclipview = [[NSClipView alloc] initWithFrame:NSMakeRect(0, 0, 500, 400)]; [myscrollview setHasVerticalScroller:YES]; [myscrollview setHasHorizontalScroller:YES]; [myscrollview setDocumentView:myclipview]; [[myscrollview documentView] scrollPoint:NSMakePoint(300.0, 300.0)]; [self.window.contentView addSubview:myscrollview]; but this isn't scrolling anywhere. I'm shure I'm missing something. Thanks for reply! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com