nstextfield

How to make marquee UILabel / UITextField / NSTextField

邮差的信 提交于 2019-11-28 20:50:51
I need to make marquee UILabel in Xcode. The marquee will scroll from right to left. I tried CCScrollingLabel also JHTickerView and others. But i can not find simple code with marquee with out any views/arrays/some stupid libraries and others How to make marquee with UILabel ? ( UITextField and NSTextField are OK too). You need NSTimer and you need to invoke a method something as : * This is for OSX, you can easily convert it into iOS, NSTextField and UILabel has different methods. -(void)awakeFromNib{ self.myTimer=[NSTimer new]; self.fullString=@"This is a long string to be shown."; [self

How do you set the text in an NSTextField?

旧巷老猫 提交于 2019-11-28 19:02:31
I'm trying to set the text in an NSTextField, but the -setStringValue: and -setTitleWithMnemonic: methods are not working. Any ideas? Ken Aspeslagh setStringValue: is the way to do it. You should make sure your outlet is being set properly. (In the debugger, make sure your textfield variable is not null.) Jim Just do something like this: myLabel.stringValue = @"My Cool Text"; Alexander Just myLabel.stringValue = "MY TEXT" works here, using Swift and Xcode 6. Swift 4 self.yourTextField.stringValue = "Your_Value" Note: Fetching value from self.yourTextField.stringValue at that will get warning

NSTextField, Change text in Swift

拥有回忆 提交于 2019-11-28 18:17:42
I can't seem to be able to change the text Label in a Mac app that I am trying to make. I am using swift. Here is the code I am using: @IBOutlet var sumlab: NSTextField! sumlab.text = "\(result.sum)" // result.sum is the result of a function I made // I also tried this: sumlab.text("\(result.sum)") // and this: sumlab.insertText("\(result.sum)") None of these seem to work and this is the only problem I need to solve to finish my program. P.S. when i write sumlab.text it says NSTextField does not have a member named text NSTextField is different from a UITextField. It doesn't have a text

Get value from NSTextField

試著忘記壹切 提交于 2019-11-28 16:36:09
I have an NSTextField and I need to get the field's value into a variable. What's the appropriate method? toholio For an NSString you would use: NSString *myString = [theTextField stringValue]; For an int you would use: int myInt = [theTextField intValue]; There are many other methods for getting the value from a control. Have a look at the NSControl reference for more info, under the "Getting and Setting the Control’s Value" section . Here's a list: doubleValue floatValue intValue integerValue objectValue stringValue attributedStringValue NilObject [myField stringValue] NSTextField inherits

NSTextField: exposing its Copy and Paste methods

折月煮酒 提交于 2019-11-28 14:16:20
I am trying to access the copy, cut, and paste methods of a NSTextField instance in its window delegate so I can customize these methods. I find that unlike tableViews and textViews, the textfield's copy, paste and cut actions are not responsive in the delegate. My understanding is that all text controls share the window's field editor yet this does not seem to be the case. I thought perhaps the TextField's field editor was not being shared with the window delegate, however I did some testing I see that as I am typing in control, those field editors are identical--very strange. My current work

Text change notification for an NSTextField

微笑、不失礼 提交于 2019-11-28 04:50:29
I would like to use the code from the answer to this question: How to observe the value of an NSTextField on an NSTextField in order to observe changes on the string stored in the NSTextField. [[NSNotificationCenter defaultCenter] addObserverForName:NSTextViewDidChangeSelectionNotification object:self.textView queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note){ NSLog(@"Text: %@", self.textView.textStorage.string); }]; The class used here is an NSTextView. I can't find a notification in NSTextField to use instead of NSTextViewDidChangeSelectionNotification. Is there a

NSTextField not calling delegate when inside an NSTableCellView

人走茶凉 提交于 2019-11-28 03:51:44
问题 I have a fairly vanilla Source List (dragged out from the Object Library) in my app, with an NSTreeController as its data source. I set the NSTextField inside the DataCell to be editable, but I want to be able to turn that off for some cells. The way I figured you would do this, is with a delegate for the NSTextField , but none of the delegate methods I've tried get called. Is there something I'm missing? I have the delegate set with an outlet in my XIB, and it happens to be the delegate to

Color attribute is ignored in NSAttributedString with NSLinkAttributeName

北城以北 提交于 2019-11-28 00:55:13
In an NSAttributedString , a range of letters has a link attribute and a custom color attribute. In Xcode 7 with Swift 2, it works: In Xcode 8 with Swift 3, the custom attributed color for the link is always ignored (it should be orange in the screenshot). Here's the code for testing. Swift 2, Xcode 7: import Cocoa import XCPlayground let text = "Hey @user!" let attr = NSMutableAttributedString(string: text) let range = NSRange(location: 4, length: 5) attr.addAttribute(NSForegroundColorAttributeName, value: NSColor.orangeColor(), range: range) attr.addAttribute(NSLinkAttributeName, value:

How to detect when NSTextField has the focus or is it's content selected cocoa

最后都变了- 提交于 2019-11-28 00:54:23
问题 I have a NSTextField inside of a NSTableCellView, and I want an event which informs me when my NSTextField has got the focus for disabling several buttons, I found this method: -(void)controlTextDidBeginEditing:(NSNotification *)obj{ NSTextField *textField = (NSTextField *)[obj object]; if (textField != _nombreDelPaqueteTextField) { [_nuevaCuentaActivoButton setEnabled:FALSE]; [_nuevaCuentaPasivoButton setEnabled:FALSE]; [_nuevaCuentaIngresosButton setEnabled:FALSE]; [

Restrict NSTextField input to numeric only? NSNumberformatter

回眸只為那壹抹淺笑 提交于 2019-11-27 22:26:09
I'm just getting started up with Mac App Development and so far everything is good well, I'm just having problems trying to get a NSTextField to only accept numbers for the input. So far I have added a formatter to the NSTextField and set it to only allow decimal now when I enter letters in the field it still allows me but does not allow my to click out of the cell when done. Ideally I would like the app not to let the user type in any letters and just beep or do nothing. Any tips or pointers on this would be great Subclass NSNumberFormatter and implement this method: - (BOOL