Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
improved moving with tab between contact form fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed Oct 4, 2013
1 parent 87cef65 commit 478eb1a
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions Hive/Controllers/HINewContactViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ - (void)loadView
[self.lastnameField.cell setPlaceholderString:NSLocalizedString(@"Lastname", @"Lastname field placeholder")];
[self.emailField.cell setPlaceholderString:NSLocalizedString(@"email", @"Email field placeholder")];

// rebind nextKeyView connections
self.lastnameField.nextKeyView = self.emailField;
self.emailField.nextKeyView = self.firstnameField;

_walletAddressFields = [NSMutableArray new];
_walletNameFields = [NSMutableArray new];
_walletRemovalButtons = [NSMutableArray new];
Expand Down Expand Up @@ -186,18 +190,14 @@ - (void)addAddressPlaceholderWithAddress:(HIAddress *)address
nameField.stringValue = address.caption ? address.caption : @"";
[nameField.cell setPlaceholderString:NSLocalizedString(@"Address caption", @"Address caption field placeholder")];
[_walletNameFields addObject:nameField];
[fieldContentView addSubview:nameField];

HITextField *addressField = [[HITextField alloc] initWithFrame:CGRectMake(10, 5, 100, 21)];
addressField.autoresizingMask = NSViewMinYMargin;
[addressField.cell setPlaceholderString:NSLocalizedString(@"Address", @"Address field placeholder")];
addressField.font = [NSFont fontWithName:@"Helvetica" size:14];
addressField.stringValue = address ? address.address : @"";
[_walletAddressFields addObject:addressField];

nameField.nextKeyView = addressField;
addressField.nextKeyView = nameField;

[fieldContentView addSubview:nameField];
[fieldContentView addSubview:addressField];

[nameField recalcForString:nameField.stringValue];
Expand All @@ -223,6 +223,18 @@ - (void)addAddressPlaceholderWithAddress:(HIAddress *)address
[addressField setEditable:NO];
[deleteButton setHidden:YES];
}

if (index == 0)
{
self.lastnameField.nextKeyView = nameField;
}
else
{
[_walletAddressFields[index - 1] setNextKeyView:nameField];
}

nameField.nextKeyView = addressField;
addressField.nextKeyView = self.emailField;
}

- (void)recalculateNames:(NSNotification *)notification
Expand Down Expand Up @@ -313,6 +325,29 @@ - (void)removeAddressClicked:(NSButton *)button
[_separators[_separators.count - 1] removeFromSuperview];
[_separators removeObjectAtIndex:_separators.count - 1];
}

if (index == 0)
{
if (_walletNameFields.count == 0)
{
self.lastnameField.nextKeyView = self.emailField;
}
else
{
self.lastnameField.nextKeyView = _walletNameFields[0];
}
}
else
{
if (index < _walletNameFields.count)
{
[_walletAddressFields[index - 1] setNextKeyView:_walletNameFields[index]];
}
else
{
[_walletAddressFields[index - 1] setNextKeyView:self.emailField];
}
}
}

- (IBAction)doneClicked:(NSButton *)sender
Expand Down

0 comments on commit 478eb1a

Please sign in to comment.