nstextfield

Label won't copy Text as typing - tried many solutions (MacOS app)

我只是一个虾纸丫 提交于 2020-05-28 11:51:26
问题 I'm new to coding and about to tear my hair out. I have a split view set up (macOS app) and I'm just trying to get a label on the left hand side to update to text entered on the right as the user is typing. I’ve been struggling for around 15+ hours with this problem. I’ve searched extensively and tried many solutions (notably those found at Swift3: Live UiLabel update on user input), below are all the attempts that have build successfully but none change the label when entering text. I’m

Restrict NSTextField to only allow numbers

狂风中的少年 提交于 2020-03-12 07:31:10
问题 How do I restrict a NSTextfield to allow only numbers/integers? I've found questions like this one, but they didn't help! 回答1: 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**

Swift NSTextField text disappears

孤街醉人 提交于 2020-02-05 02:33:05
问题 This questions MIGHT exist on a 6 year old post in objective-c. I haven't found a recent answer or question that works, or one that is written in Swift. I'm using storyboards and I have subclassed NSTextField . For some reason when I click into the field, the placeholder shows and when I enter text and click out, the text disappears. The text is actually there, because when I click back in, the entered text persists. It seems that it's some type of rendering issue that a layer is covering up

NSTextField enter to trigger action

折月煮酒 提交于 2020-01-28 05:40:46
问题 I've been looking all over for a simple example of how to have an action (or button) be triggered when the enter key is hit in the text field. Should I subclass the text field? Would I need to set a delegate to call the action I need? Is there a way to catch the event in my main window controller class? If you could even just point me to the right direction that would be great. Thanks. 回答1: To get action after you hit enter just write an IBAction in your window controller and connect to your

How to bind a NSTextField to a raw string while displaying another attributed string?

怎甘沉沦 提交于 2020-01-24 20:14:29
问题 I'm using view-based NSTableView and would like to allow users to edit text in place. Cocoa typically has superb support for this, but I am not sure how to bind the value of NSTextField to one string while displaying a slightly different string to the user, as shown below. For example, when user clicks on a text field or presses enter key to edit, the field editor should only be filled with exportTest.zip and not exportTest.zip Shared , and whatever edit user makes should only affect the

How to bind a NSTextField to a raw string while displaying another attributed string?

拈花ヽ惹草 提交于 2020-01-24 20:13:22
问题 I'm using view-based NSTableView and would like to allow users to edit text in place. Cocoa typically has superb support for this, but I am not sure how to bind the value of NSTextField to one string while displaying a slightly different string to the user, as shown below. For example, when user clicks on a text field or presses enter key to edit, the field editor should only be filled with exportTest.zip and not exportTest.zip Shared , and whatever edit user makes should only affect the

Why does an NSTextField leave artifacts over an NSTableView when the table scrolls?

自作多情 提交于 2020-01-24 16:08:29
问题 I want to put a text label over a scroll table but the label conflicts with the drawing of the scrolling. Here you can see a test where I've intentionally put the label half out of the table and scroll up in the table, which results in the part of the label overlay being dragged below until it exits the window. Also, when I go to the other end of the table and scroll down, sometimes the label seems to be redrawn and chunks of it go up along with the scroll: It seems that the table is

NSTextField bounce truncated text instead of wrapping

徘徊边缘 提交于 2020-01-24 09:30:29
问题 I was wondering if there was a simple way to "bounce" or scroll an NSTextField with text thats too long to display. For Example: ----------------------------- <-- scroll | This is a rather large pi | ..ece of text! ----------------------------- So in this example, the text would scroll to the end, showing the rest of the message, then back to the beginning where it will rest; basically giving the user a peak at all of the text. ----------------------------- This is a ra.. | ther large piece

-[NSTextField intrinsicContentSize] always has undefined width

萝らか妹 提交于 2020-01-21 11:26:27
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I

-[NSTextField intrinsicContentSize] always has undefined width

和自甴很熟 提交于 2020-01-21 11:25:29
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I