Этот ответ соответствует названию вопроса, но не самому вопросу.Омер хотел коснуться текстового поля и открыть всплывающее окно.
Это решение показывает всплывающее окно, когда пользователь вводит текст.
Я нашел этот ответ на cocoabuilder от Jens Alfke .Я сохранил его код здесь.Спасибо, Дженс.
оригинальный пост Cocoabuilder: (http://www.cocoabuilder.com/archive/cocoa)
@interface NSComboBox (MYExpansionAPI)
@property (getter=isExpanded) BOOL expanded;
@end
@implementation NSComboBox (MYExpansionAPI)
- (BOOL) isExpanded
{
id ax = NSAccessibilityUnignoredDescendant(self);
return [[ax accessibilityAttributeValue:
NSAccessibilityExpandedAttribute] boolValue];
}
- (void) setExpanded: (BOOL)expanded
{
id ax = NSAccessibilityUnignoredDescendant(self);
[ax accessibilitySetValue: [NSNumber numberWithBool: expanded]
forAttribute: NSAccessibilityExpandedAttribute];
}
Я использовал этот код в своем методе controlTextDidChange:
.
- (void) controlTextDidChange:(NSNotification *) aNotification {
NSTextField *textField = [aNotification object];
NSString *value = [textField stringValue];
NSComboBox *box = [self comboBox];
if (value == nil || [value length] == 0) {
if ([box isExpanded]) { [box setExpanded:NO]; }
} else {
if (![box isExpanded]) { [box setExpanded:YES]; }
}
}