nstextfield

Creating a label using NSTextField is blurry

我与影子孤独终老i 提交于 2019-12-01 05:27:41
I'm trying to create a label programmatically using NSTextField, but it comes out blurry: screenshot This is my code so far: NSTextfield *textfield = [[NSTextField alloc] initWithFrame:NSMakeRect(5,5,150,20)]; [texField setStringValue:@"some text here"]; [textField setEditable:NO]; [textField setSelectable:NO]; [textField setBordered:NO] [textField setDrawsBackground:NO] I've traced the problem down to the setDrawsBackground line. I've also tried using [textField setBackgroundColor:[NSColor clearColor] as well, but no luck. By the way, I've adding to a textField to the subview of a view that

Creating a label using NSTextField is blurry

主宰稳场 提交于 2019-12-01 03:41:39
问题 I'm trying to create a label programmatically using NSTextField, but it comes out blurry: screenshot This is my code so far: NSTextfield *textfield = [[NSTextField alloc] initWithFrame:NSMakeRect(5,5,150,20)]; [texField setStringValue:@"some text here"]; [textField setEditable:NO]; [textField setSelectable:NO]; [textField setBordered:NO] [textField setDrawsBackground:NO] I've traced the problem down to the setDrawsBackground line. I've also tried using [textField setBackgroundColor:[NSColor

Custom fonts in Mac sdk using storyboard

自闭症网瘾萝莉.ら 提交于 2019-12-01 01:55:53
How to add a custom font to storyboard in Mac app development. I went through some blogs and tried by adding font book and develop one NStextfield using this custom font using storyboard. But it is system dependent. I created the DMG and install in another computer it uses the default font. I did it programmatically, but my requirement is through storyboard. Please help me on this I spent a bit of time trying to figure this out and found the solution in this related question . In your info.plist file, which you made available to me at It turns out you can safely get rid of the "Fonts Provided

How to add data from an NSTextField to a Core Data Attribute without having to press Return or Tab after editing the TextField?

蹲街弑〆低调 提交于 2019-11-30 20:11:55
问题 I use a sheet with 3 NSTextFields and a Cancel- and OK-Button to edit the attributes of a Core Data Entity. The text entered in the NSTextFields is only updated in the Core Data Entity if i press Tab or Return after writing in the NSTextField or if i focus another NSTextField with the mouse. If i just enter text in an NSTextField and press the OK-Button the entered text is lost. Is there some attribute i can set in Interface Builder to change this NSTextField behaviour? 回答1: The answer in my

NSTextField Vertical alignment

五迷三道 提交于 2019-11-30 17:27:07
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]]; [superView addSubview:myTextField]; [superView setAutoresizesSubviews:YES]; [myTextField setAutoresizingMask

NSTextField enter key detection or firstResponder detection

与世无争的帅哥 提交于 2019-11-30 17:03:33
问题 I have two NSTextField s: textFieldUserID and textFieldPassword . For textFieldPassword , I have a delegate as follows: - (void)controlTextDidEndEditing:(NSNotification *)aNotification This delegate gets called when textFieldPassword has focus and I hit the enter key. This is exactly what I want. My problem is that controlTextDidEndEditing also gets called when textFieldPassword has focus and I move the focus to textFieldUserID (via mouse or tab key). This is NOT what I want. I tried using

NSTextField in NSTableCellView

馋奶兔 提交于 2019-11-30 10:23:44
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? Probably the easiest way to accomplish this would be to subclass NSTextField and to override the drawRect: method in your subclass. There you can determine whether the NSTableCellView instance containing your NSTextField instances is

Truncate the last line of multi-line NSTextField

风格不统一 提交于 2019-11-30 10:00:42
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: deleted_user If you want to wrap text like finder labels, using two labels doesn't do you any good since you need to know what the maximum breakable amount of text is on the first line. Plus, if you're building

NSWindow textured background with NStextField

天涯浪子 提交于 2019-11-30 07:43:29
I have a super strange problem. I want a Textured window to have it normal gradient color. I have an NSTextField in this window, the text field is destined to be an URL input field so it need to be large. The problem is that when it is too large (approximately more than 1/3 of the window width) it just switch the textured window to draw a darker version of it gradient. Here is an example project (very simple...) for you to test. http://raven.ipodtutofast.com/test.zip When you will build and run it notice the background of the window, initial one is fine, now make the window bigger, it will

Intercepting NSMenu key events

冷暖自知 提交于 2019-11-30 07:42:17
问题 I am making a search field, which opens a NSMenu similar to Finder and Mail The only problem, which drives me crazy, is that i cannot intercept the key events, once the menu is open I even subclassed the NSApplication sendEvent, but was surprised to find out, that during menu, there is no call to Applications sendAction: I subclassed performKeyEquivalent: NSMenu but it is not called - (BOOL)performKeyEquivalent:(NSEvent *)theEvent I am listening for the delegate call on menuHasKeyEquivalent: