Cocoa: how to implement custom NSView with editable text area?

What is the minimum implementation required to create a custom NSView with an editable text area? I assume that you can use NSTextFieldCell for this. I managed to draw a cell in the view (which is straightforward), but editing it might require more complex coordination between the view and the cell. Is there somewhere code example?

Refresh. I should have made it clear that my long-term goal is to have many more editable text areas in the same view. AFAIU is better to use cells in this case, since they are lighter than full-size representations. My updated question is: what is the minimum implementation needed to create a custom NSView with an editable text area using the appropriate NSCell?

+3
source share
3 answers

What is the minimum implementation required to create a custom NSView with an editable text area?

, NSViews ( ) NSView, NSTextField - NSView.

, , , , , . @interface ( , ).

, , , . , .

, NSTextFieldCell.

, NSTextField. NSTextField .

+1

(, ), NSMatrix NSTextFieldCells. , , NSMatrix .

+1

, editWithFrame:inView:editor:delegate:event: . , NSEvent , . selectWithFrame:inView:editor:delegate:start:length:, . , .

, , endEditing: .

+1
source

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


All Articles