Skip to content

Instantly share code, notes, and snippets.

@hammerdr
Forked from Synvox/Event.j
Created May 22, 2011 22:17
Show Gist options
  • Save hammerdr/985962 to your computer and use it in GitHub Desktop.
Save hammerdr/985962 to your computer and use it in GitHub Desktop.
Cappuccino Instance Variables Problem
/*
* Event.j
* Canvas Creator
*
* Created by Ryan on May 21th, 2011.
* Copyright 2011, Synvox rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPView.j>
@import "EventsView.j"
@import "Action.j"
@implementation Event : CPView
{
CPMutableArray actions;
}
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
actions = [[CPMutableArray alloc] init];
[actions addObject:[[Action alloc] initWithType:@"Something"]];
[self setBackgroundColor:[CPColor colorWithCalibratedRed:.95 green:.95 blue:.95 alpha:1]];
}
alert(actions.length);
return self;
}
- (void)setSelected:(BOOL)isSelected
{
if (isSelected){
[self select];
} else {
[self deselect]
}
}
-(void)select
{
[self setBackgroundColor:[CPColor colorWithCalibratedRed:.35 green:.60 blue:.85 alpha:1]];
alert(actions.length);
[[self eventView] view:actions];
}
-(void)deselect
{
[self setBackgroundColor:[CPColor colorWithCalibratedRed:.95 green:.95 blue:.95 alpha:1]];
}
-(EventsView)eventView
{
return [[[[self superview] superview] superview] superview];
}
var EventActionsKey = "EventActionsKey";
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
actions = [aCoder decodeObjectForKey:EventActionsKey];
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:actions forKey:EventActionsKey];
[super encodeWithCoder:aCoder];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment