0

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.

4

2 Answers 2

1

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
    */
}
Sign up to request clarification or add additional context in comments.

5 Comments

Sorry but actually none of the answers you suggested helped me. Can you please make me an example?
access an NSComboBox object which present in my interface builder from this class. in which class, it is?
"use the shared instance of comboBox here and make it hidden." Can you please make me an example of code since I am a newbie in cocoa programming? thank you.
Any idea? I'll try to explain you all what I'm trying to do again: I have an NSTextfield and an NSComboBox. Well I want the NSTextField to disappear and the NSComboCox to appear when some one clicks inside the NSTextField. Help me. Thank you.
0

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 IBOutlets for txtField1 and combobox) and in method – control:textView:doCommandBySelector: implement hiding of your NSComboBox

2 Comments

Any idea? I'll try to explain you all what I'm trying to do again: I have an NSTextfield and an NSComboBox. Well I want the NSTextField to disappear and the NSComboCox to appear when some one clicks inside the NSTextField. Help me. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.