Is there a workable way to make NSPredicateEditor resize NSTextField?
All I got is to subclass NSPredicateEditorRowTemplate and write in my class the following function:
- (void)setTextFieldFrameWithPredicateEditor:(NSPredicateEditor *)predicateEditor{
NSArray *arr = [self templateViews];
NSView *view = [arr lastObject];
NSSize needSize = NSMakeSize(NSMaxX(predicateEditor.frame), 17);
[view setFrameSize:needSize];
}
There is no effect from setting anchors(margins) by [view setAutoresizingMask:(NSViewMaxXMargin | NSViewWidthSizable)]
I call this function every time the show NSPredicateEditor by pressing a button, and every time in function -(IBAction)predicateEditorChanged:(NSPredicateEditor *)sender. It seems working correctly, but when many times I change the settings NSPredicateEditor at some time resizing starts to work not correct.
Any help please.
One option would be to create a custom NSPredicateEditorRowTemplate and override the templateViews method.
Like this:
- (NSArray *)templateViews {
NSArray *views = [super templateViews];
NSView *lastView = [views lastObject];
NSRect viewFrame = lastView.frame;
viewFrame.size.width = 100.0f;
lastView.frame = viewFrame;
return views;
}
And then set the width to whatever you need it to be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With