Skip to content

Instantly share code, notes, and snippets.

@saikat
Created July 15, 2010 00:29
Show Gist options
  • Save saikat/476333 to your computer and use it in GitHub Desktop.
Save saikat/476333 to your computer and use it in GitHub Desktop.
/*
* AppController.j
* TestCustomDOMElement
*
* Created by You on July 14, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation CustomView : CPView
{
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self) {
_DOMElement.onmousedown = function(aDOMEvent) {
console.log(aDOMEvent);
// UNCOMMENT THESE LINES IF YOU WANT CAPPUCCINO MOUSE DOWN TO STOP WORKING
// if (aDOMEvent.preventDefault)
// aDOMEvent.preventDefault();
// if (aDOMEvent.stopPropagation)
// aDOMEvent.stopPropagation();
};
}
return self;
}
- (void)mouseDown:(CPEvent)anEvent
{
console.log("Mouse down event");
}
@end
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var customView = [[CustomView alloc] initWithFrame:CGRectMake(50, 50, 500, 500)];
var label = [CPTextField labelWithTitle:"Hello world"];
[label setSelectable:YES];
[customView setBackgroundColor:[CPColor redColor]];
[contentView addSubview:customView];
[contentView addSubview:label];
[theWindow orderFront:self];
// Uncomment the following line to turn on the standard menu bar.
//[CPMenu setMenuBarVisible:YES];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment