Search code examples
objective-ccocoanstextfieldnsbutton

NSButton Inside NSTextField


I'm trying to create a NSTextField with a button on its right side (similar to a NSSearchView), but I can't figure out how to have the NSTextField's text scroll without going under the NSButton.

Here is my code thus far:

rightButton = [[NSButton alloc] initWithFrame:rect];
[rightButton setTarget:self];
[[rightButton cell] setHighlightsBy:NSNullCellType];
[rightButton setImage:[NSImage imageNamed:@"rightButton"]];
[rightButton setAction:@selector(action:)];
[rightButton setBordered:NO];

Any thoughts?

EDIT: Here is a screenshot of the problem. Screenshot of the bug.


Solution

  • I think this is what you're looking for. Basically what you're doing is adjusting the frame to compensate for the button you put inside the field.