0

I want to manipulate the baseline when typing text in an NSTokenField to match the displayed tokens. To do so, I'm following the guide "Working With the Field Editor" in the documentation. There it is recommended to override the method - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj; of the associated NSTextFieldCell to adjust the field editors properties before editing. Here's what I do there:

- (NSText *)setUpFieldEditorAttributes:(NSText *)textObj {
    textObj = [super setUpFieldEditorAttributes:textObj];
    if([textObj isKindOfClass:[NSTextView class]]) {
        NSTextView *fieldEditor = (NSTextView *)textObj;
        [fieldEditor raiseBaseline:self];
        [fieldEditor raiseBaseline:self];
        [fieldEditor raiseBaseline:self];
        NSLog(@"Raised editor baseline");
    }
    return textObj;
}

As I can confirm with the help of the log, the method get's called. However, the baseline doesn't change at all while editing. Also calling other methods like [fieldEditor loosenKerning:self] that should produce a visible result don't seem to be having any effect. What am I doing wrong here or better - how can I achieve what I want to?

Jan Z.
  • 6,883
  • 4
  • 23
  • 27
  • `raiseBaseline:` "Raises the baseline offset of **selected text**" – Willeke Feb 25 '22 at 13:17
  • This seems to answer the question. Do you have any idea how to set the baseline for the whole view while editing, not only a selection? – Jan Z. Feb 25 '22 at 14:00

0 Answers0