Skip to content

Commit

Permalink
Prev/Next navigation fix so that we could "jump over", for instance, …
Browse files Browse the repository at this point in the history
…QRadioElement, that is also a QEntryElement, but is not focusable
  • Loading branch information
HiveHicks authored and Craig Earley committed Aug 3, 2012
1 parent 044b967 commit 7e97842
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion quickdialog/QEntryElement.h
Expand Up @@ -43,6 +43,8 @@


- (QEntryElement *)init;

- (QEntryElement *)initWithTitle:(NSString *)string Value:(NSString *)param Placeholder:(NSString *)string1;

- (BOOL)canTakeFocus;

@end
3 changes: 3 additions & 0 deletions quickdialog/QEntryElement.m
Expand Up @@ -72,6 +72,9 @@ - (void)fetchValueIntoObject:(id)obj {
[obj setValue:_textValue forKey:_key];
}

- (BOOL)canTakeFocus {
return YES;
}

#pragma mark - UITextInputTraits

Expand Down
10 changes: 6 additions & 4 deletions quickdialog/QEntryTableViewCell.m
Expand Up @@ -260,13 +260,14 @@ - (BOOL)resignFirstResponder {
}

- (QEntryElement *)findPreviousElementToFocusOn {

QEntryElement *previousElement = nil;
for (QSection *section in _entryElement.parentSection.rootElement.sections) {
for (QElement * e in section.elements){
for (QElement *e in section.elements) {
if (e == _entryElement) {
return previousElement;
}
else if ([e isKindOfClass:[QEntryElement class]]){
else if ([e isKindOfClass:[QEntryElement class]] && [(QEntryElement *)e canTakeFocus]) {
previousElement = (QEntryElement *)e;
}
}
Expand All @@ -275,13 +276,14 @@ - (QEntryElement *)findPreviousElementToFocusOn {
}

- (QEntryElement *)findNextElementToFocusOn {

BOOL foundSelf = NO;
for (QSection *section in _entryElement.parentSection.rootElement.sections) {
for (QElement * e in section.elements){
for (QElement *e in section.elements) {
if (e == _entryElement) {
foundSelf = YES;
}
else if (foundSelf && [e isKindOfClass:[QEntryElement class]]){
else if (foundSelf && [e isKindOfClass:[QEntryElement class]] && [(QEntryElement *)e canTakeFocus]) {
return (QEntryElement *) e;
}
}
Expand Down
3 changes: 3 additions & 0 deletions quickdialog/QMultilineElement.m
Expand Up @@ -65,5 +65,8 @@ - (void)fetchValueIntoObject:(id)obj
[obj setValue:self.textValue forKey:_key];
}

- (BOOL)canTakeFocus {
return NO;
}

@end
3 changes: 3 additions & 0 deletions quickdialog/QRadioElement.m
Expand Up @@ -140,5 +140,8 @@ - (void)fetchValueIntoObject:(id)obj {
}
}

- (BOOL)canTakeFocus {
return NO;
}

@end
4 changes: 4 additions & 0 deletions quickdialog/QSegmentedElement.m
Expand Up @@ -50,4 +50,8 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr
return cell;
}

- (BOOL)canTakeFocus {
return NO;
}

@end

0 comments on commit 7e97842

Please sign in to comment.