Subclass NSTextField

I want to extend the functionality of NSTextField. Among the things I want to achieve are:

Change the appearance of the carriage.

Detecting when text reaches a certain number of characters and then coloring the text after this restriction in different ways. *

To my great disappointment, having spent quite a lot of time searching on Google, I find hundreds of hits that simply state "Subclass NSTextField and use this code", and, to my humiliation, I can’t understand how to do this.

I would greatly appreciate if someone would give me a working example of a subclass that does one of the two things listed above and instructions * on how to implement the code so that I can try to figure out how it works by looking at some of them. actual live code.


I really apologize for my late reply!

Apologies to all of you. I have colic at home, and as you (or at least those of you who have children), you can imagine that it takes up a lot of your free time. Thank you all for your answers.

I see that one of my main problems is that I don’t have enough understanding of delegates and outlets. I bought the book recommended here (and in many other places. Some kind of "Bible" that I collect), and I study it when we speak in those few silent hours that I have these days. :)

, , , , *, , - . , , , NSTextfield?

, , " ", , . !

, ; , , , , , . Interface Builder GUI . .


* , - Twitter.

*

* , . , AS3

0
5

Martin,

" " "Cocoa" , Objective-C.

. , , NSObject "@interface" "NSTextView", . XCode 3.0, Interface Builder NSTextField "MyTextView".

Aaron Hillegass "Cocoa Mac OS X, ". Leopard, .

.


#import <Cocoa/Cocoa.h>


@interface MyTextView : NSTextView {
 // Outlets & Members go here
}
// Actions & messages go here
@end


#import "MyTextView.h"


@implementation MyTextView

@end

+3

setInsertionPointColor: , . , Cocoa ; , , , - .

+5

NSTextField , . ( ) NSTextView, . NSTextField. NSWindow (!) -fieldEditor:forObject:. , , NSTextFieldCell s -setUpFieldEditorAttributes:, , , , .

: Cocoa, .

+4
+3

, .

+1

Source: https://habr.com/ru/post/1706666/


All Articles