Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @import <Foundation/CPObject.j>
- @implementation AccountBarView : CPView
- {
- CPSecureTextField passwordField;
- CPTextField usernameField;
- }
- - (id)initWithFrame:(CGRect)aFrame
- {
- self = [super initWithFrame: aFrame];
- if (self)
- {
- [self setBackgroundColor: [CPColor colorWithHexString:@"666"]];
- [self setAutoresizingMask: CPViewWidthSizable];
- //[self setAutoresizingMask: CPViewMinXMargin | CPViewMaxXMargin]; // to make it stick to the right edge, tell it to let CPViewMinXMargin (left) be flexible
- var bounds = [self bounds];
- // create input fields for username and password
- usernameField = [[CPTextField alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-340,10,100,21)];
- [usernameField setBezeled: YES];
- //[usernameField setBordered: YES]; // what is bordered supposed to do?
- [usernameField setEditable: YES];
- [usernameField setBezelStyle: CPTextFieldSquareBezel];
- [usernameField setTextFieldBackgroundColor: [CPColor colorWithHexString:@"333"]];
- [usernameField setAutoresizingMask: CPViewMinXMargin];
- [self addSubview: usernameField];
- passwordField = [[CPSecureTextField alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-220,10,100,21)];
- [passwordField setBezeled: YES];
- [passwordField setEditable: YES];
- [passwordField setBezelStyle: CPTextFieldSquareBezel];
- [passwordField setTextFieldBackgroundColor: [CPColor colorWithHexString:@"333"]];
- [passwordField setAutoresizingMask: CPViewMinXMargin];
- [self addSubview: passwordField];
- // add submit button
- var submit = [[CPButton alloc] initWithFrame: CGRectMake(CPRectGetWidth(bounds)-100,12,60,18)];
- [submit setBezelStyle: CPRoundRectBezelStyle];
- [submit setTitle: @"Log in"];
- [submit setAutoresizingMask: CPViewMinXMargin];
- [submit setTarget: self];
- [submit setAction: @selector(credentialsSubmitted)];
- [self addSubview: submit];
- // add logo
- var logo = [[CPImage alloc] initWithContentsOfFile: @"Resources/Logo.png" size: CPSizeMake(174, 36)];
- var logoView = [[CPImageView alloc] initWithFrame: CGRectMake(10,2,174,36)];
- [logoView setAutoresizingMask: CPViewMaxXMargin];
- [logoView setImage: logo];
- [self addSubview: logoView];
- }
- return self;
- }
- - (void)credentialsSubmitted
- {
- var username = [usernameField stringValue];
- var password = [passwordField stringValue];
- CPLog(@"username: %@, password: %@", username, password);
- }
Add Comment
Please, Sign In to add comment