nstextfield

How to observe the value of an NSTextField

我怕爱的太早我们不能终老 提交于 2019-12-14 03:57:31
问题 This might seem straightforward, but the following code does not work, because the "observeValueForKeyPath" function is never called, although I keep changing the text in the NSTextfield: - (void)awakeFromNib { [myNSTextField addObserver:self forKeyPath:@"value" options:NSKeyValueObservingOptionOld context:nil]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { NSLog(@"observeValueForKeyPath"); } The log message @

NSTextField with suggestions drop-down

ε祈祈猫儿з 提交于 2019-12-13 12:37:17
问题 Instead of implementing my own, I am looking into reusing an existing custom NSTextField that has support for suggestions drop-down - Same as the one in the browser as you type you get a list of suggestions underneath. Do you know any good ones? Thank you! 回答1: They're called completions. You still use a regular text field but add this: control:textView:completions:forPartialWordRange:indexOfSelectedItem The biggest problem is you need to provide the list of words that can be autocompleted.

Can I prevent text highlight when I hit “return” keystroke on a NSTextField?

此生再无相见时 提交于 2019-12-12 22:24:33
问题 Before I hit "return" keystroke: After I hit "return" keystroke: I don't want that highlight, just want to keep it unchanged. How can I do that? Here is the code snippet for this text field: let searchField = NSTextField() searchField.isBezeled = false searchField.drawsBackground = false searchField.textColor = .white searchField.focusRingType = .none searchField.usesSingleLineMode = true searchField.cell?.sendsActionOnEndEditing = false searchField.target = self searchField.action =

NSTextField weird left margins

眉间皱痕 提交于 2019-12-12 10:21:55
问题 I've been looking for a solution for this one all day. I have 4 NSTextFields (actually subclassed for a few custom operations), which all share the same X position. The problem is, some have different styles (light, regular, bold) and might have different sizes. What happens is that, even though the X origin is the same, the 1st letter always has a bit of (consistently different) left margins. Please see pic: https://dl.dropbox.com/u/1977230/Screen%20Shot%202012-12-11%20at%2017.55.58.png I

Cocoa/OSX - NSTextField not responding to click for text editing to begin when titlebar is hidden

a 夏天 提交于 2019-12-12 09:42:35
问题 I have a NSTextField in my window (added with IB) with a hidden title bar but when I click on it when the app is running, it does not respond or place a cursor in its field. Is there anything I am doing wrong? it is setup in the most standard way possible, an editable textfield on a window. Thanks. 回答1: Create a custom class that inherits from NSWindow, and set it as the NSWindow Object in InterfaceBuilder. Then override the following methods: // // canBecomeKeyWindow // // Overrides the

Custom fonts in Mac sdk using storyboard

放肆的年华 提交于 2019-12-12 07:24:11
问题 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 回答1: I spent a bit of time trying to figure this out and found the solution in this related question. In your

Objective-C, auto erase NSTextField string

徘徊边缘 提交于 2019-12-12 04:55:45
问题 I've been trying to figure out how to auto erase a string within an NSTextField upon clicking within in it. For example the current behavior is like this on OSX: When a user clicks in the cell or the default focus is the cell either the word is sometimes highlighted or the cursor is placed in the middle of the text. The user then needs to use backspace to delete the text (which I'd like to eliminate by automatically removing the text). Is this a function that is built-in that I'm somehow

Swift: NSTextField numberStyle not calling action

余生颓废 提交于 2019-12-12 04:26:16
问题 I have a NSTextField that I have setup with the following code: func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? { let cell : NSTableCellView? = tableView.makeViewWithIdentifier("AutomaticTableColumnIdentifier.0", owner: self) as! NSTableCellView? cell!.textField!.floatValue = 4.55 let numberFormatter = NSNumberFormatter() numberFormatter.numberStyle = .CurrencyStyle numberFormatter.maximumFractionDigits = 0 cell!.textField! =

Disable NSTextField without changing color of multi-colored text

拈花ヽ惹草 提交于 2019-12-12 01:33:02
问题 Whenever I disable an NSTextField the text loses its color and changes to gray. How can I disable the text field and keep the text color? In my particular situation some words are colored red. I'd like those words to stay red when I disable. 回答1: You need to subclass NSTextField to do that. See this CocoaBuilder thread: - (void)setEnabled:(BOOL)flag { [super setEnabled:flag]; if (!flag) { [self setTextColor:[NSColor secondarySelectedControlColor]]; } else { [self setTextColor:[NSColor

Why does Xamarin.Mac window abruptly disappear?

限于喜欢 提交于 2019-12-12 01:06:23
问题 I recently posted about a bug in MonoMac in which the window would abruptly disappear after clicking on a button 20 times or so. That bug, it turned out, doesn't seem to affect Xamarin.Mac, so I switched my project to that. But now I'm seeing virtually the same bug in a different context: after typing a few lines of text into an NSTextField, the window disappears in exactly the same manner. No error, no exception; it just vanishes. Poof, gone! I've reproduced this in a trivial project: you