nstextfield

NSString boundingRectWithSize slightly underestimating the correct height - why?

巧了我就是萌 提交于 2019-11-30 07:25:55
问题 I'm attempting to resize a text field / view automatically depending on its current width. In other words I want the width to stay constant but resize the height according to the text supplied to it. It seems to be working but for some reason is aligning to the bottom of my window despite efforts to manually move it back. Can anybody see what I'm doing wrong here? NSString *temp = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer vel felis nec massa ultricies blandit non id

NSTextField like safari address bar

旧时模样 提交于 2019-11-30 03:30:42
问题 Whats the best way to go about building an address field like the one in safari? Needs to have editable text, and determinate progress indicator background. 回答1: You could just subclass NSTextField and override the -drawRect: method to "fill" the appropriate percentage of the entire width with some color or gradient (or whatever) for the progress. If I'm understanding your question right. -(void)drawRect:(NSRect)dirtyRect { CGFloat progress = 0.33; NSRect progressRect = [self bounds];

NSTextField with “padding” on the right

守給你的承諾、 提交于 2019-11-30 02:31:18
I am trying to get the "remaining chars notice" to show up within my rounded NSTextField and I got it with two NSTextFields with help of the Interface Builder and it already looks like that: alt text http://jeenaparadies.net/t/s/Twittia-NSTextField1.png But when I write a little bit more it looks like that: alt text http://jeenaparadies.net/t/s/Twittia-NSTextField2.png The only thing I could think of is to subclass NSTextField and do something with it so it does not draw text under the number but I have no idea how to begin and need really some help with it. The simplest way is probably to

can't edit NSTextField in sheet at runtime

◇◆丶佛笑我妖孽 提交于 2019-11-30 01:24:20
When clicking on a button, I'd like to display a sheet with an email+password prompt with options to save and cancel. The UI is all set up, the actions are in place, and the sheet appears and cancels as expected. The problem is that I can't edit either of the NSTextFields at runtime; they appear to disabled, and the OS error sound plays on every key press when the sheet is open. I read on SO that UIActionSheet is appropriate, but this is not an iOS app. The textfields are enabled, and had previously been working in another panel. I made sure that the IBAction links are intact, but I'm

NSTextField Vertical alignment

≯℡__Kan透↙ 提交于 2019-11-30 01:17:19
问题 I am creating cocoa app in which i created NSTextField programmatically like this, NSView *superView = [[NSView alloc] initWithFrame:NSMakeRect(0, 300, 1400, 500)]; NSTextField *myTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(180, 100, 1000, 300)]; [myTextField setStringValue:myText]; [myTextField setEditable:NO]; [myTextField setBezeled:NO]; [myTextField setDrawsBackground:NO]; [myTextField setSelectable:NO]; [myTextField setFont:[NSFont fontWithName:@"Futura" size:22]];

NSTextField or NSTextView?

不想你离开。 提交于 2019-11-29 22:58:00
Could someone explain to me what are the main differences between NSTextField and NSTextView? I know that NSTextView has more features and is usually used for longer texts, and NSTextField is usually used for one-line plain text fields, but if I understand correctly, NSTextField can be also used with attributed strings and with multiple lines... What I need specifically is a control that would display the text of messages inside a timeline view like in Tweetie or any other similar software. The only requirements I have are: it should display text in about 1-4 lines it should be able to show

Restrict NSTextField to only allow numbers

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 22:24:37
How do I restrict a NSTextfield to allow only numbers/integers? I've found questions like this one, but they didn't help! Try to make your own NSNumberFormatter subclass and check the input value in -isPartialStringValid:newEditingString:errorDescription: method. @interface OnlyIntegerValueFormatter : NSNumberFormatter @end @implementation OnlyIntegerValueFormatter - (BOOL)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error { if([partialString length] == 0) { return YES; } NSScanner* scanner = [NSScanner scannerWithString

NSTextField transparent background

只愿长相守 提交于 2019-11-29 20:53:43
I create transparent NSTextField self.myTextField = [[NSTextField alloc] initWithFrame:CGRectMake(backgroundView.frame.origin.x + backgroundView.frame.size.width + 20, self.projectTitle.frame.origin.y - 30.0, 100, 20)]; self.myTextField.editable = NO; self.myTextField.bezeled = NO; self.myTextField.drawsBackground = YES; self.myTextField.backgroundColor = [NSColor clearColor]; self.myTextField.selectable = NO; self.myTextField.font = [NSFont fontWithName:@"Helvetica Neue" size:16]; [self addSubview:self.compressingTime]; And as a result text look bad. If I set background color self.myTextField

NSTextField in NSTableCellView

爷,独闯天下 提交于 2019-11-29 15:38:28
问题 I have a view based NSTableView with a custom NSTableCellView. This custom NSTableCellView has several labels (NSTextField). The whole UI of the NSTableCellView is built in IB. The NSTableCellView can be in a normal state and in a selected state. In the normal state all text labels should be black, in the selected state they should be white. How can I manage this? 回答1: Probably the easiest way to accomplish this would be to subclass NSTextField and to override the drawRect: method in your

Truncate the last line of multi-line NSTextField

情到浓时终转凉″ 提交于 2019-11-29 15:01:03
问题 I'm trying to create a text field similar to Finder's file labels. I would like the last (second) line to be truncated in the middle. I started with a multi-line NSTextField . However, calling [self.cell setLineBreakMode:NSLineBreakByTruncatingMiddle]; results in a the text field showing only a single truncated line (no line breaks anymore). Here is what it looks like in Finder: 回答1: If you want to wrap text like finder labels, using two labels doesn't do you any good since you need to know