Reputation: 99
I have an NSTextField subclass (called "txtField1" and used as Custom Class for a Text Field in my interface builder) and I would like to be able to access an NSComboBox object which present in my interface builder from this class.
This is my code: txtField1.h:
#import <Cocoa/Cocoa.h>
@interface txtField1 : NSTextField
@end
txtField.m:
#import "txtField1.h"
@implementation txtField1
-(void)mouseDown:(NSEvent *)theEvent
{
HERE I would like to be able to write something like:
[combobox SetHidden:YES];
}
@end
I would like to be able to set access the combobox SetHidden property, in the mouseDown event. Can you please tell me how to do that? I have tried different solutions found on internet but didn't obtain anything at all! Any help would be appreciated.
Upvotes: 0
Views: 783
Reputation: 46543
Here are a lot of ways, and answers here, to do :
Update a label through button from different view
Xcode - update ViewController label text from different view
Setting label text in another class
Set label on another view to stored NSDate
EDIT:
-(void)mouseDown:(NSEvent *)theEvent
{
HERE I would like to be able to write something like:
[combobox SetHidden:YES];
/*
use the shared instance of comboBox here and make it hidden.
Also, you can use binding to make it hidden
*/
}
Upvotes: 1
Reputation: 5657
From my point of view txtField1
class is not better place to this code.
You can add NSControlTextEditingDelegate
protocol to your NSViewController
implementation (that already contains IBOutlet
s for txtField1
and combobox
) and in method – control:textView:doCommandBySelector:
implement hiding of your NSComboBox
Upvotes: 0