nsslider

Swift: How to continuously send an action from a NSTextField

隐身守侯 提交于 2019-12-23 04:43:46
问题 I have a NSTextField and want to send an action whenever the user changes the value. I checked "Continuous" in the Interface Builder (which works i.e. fine with NSSlider), but the NSTextField only sends his action if I unfocus it. How can I continuously send an action from a NSTextField (using Swift)? 回答1: Set the delegate of the text field to the class which is supposed to receive the action and implement func controlTextDidChange(_ obj: NSNotification) This method is invoked when text in a

NSSlider animation

元气小坏坏 提交于 2019-12-18 16:55:43
问题 How can I create NSSlider animation when changing float value of it. I was trying: [[mySlider animator] setFloatValue:-5]; but that didn't work.. just change the value without animation. So maybe someone knows how to do this? Thanks in advance. 回答1: Ok - so this isn't as quick and pretty as I hoped but it works. You can't actually use animators and Core Animation on the slider knob - because Core Animation works only on layers and there's no access to the knob values in the slider layer. So

change NSSlider Value programmatically

一个人想着一个人 提交于 2019-12-18 05:50:37
问题 Is there a way to make an IBOutlet of an NSSlider and then be able to change its value programmatically? slider.value = ...does not work. Thanks! 回答1: You can use the methods of NSControl. Example: [self.slider setDoubleValue:0.1]; 回答2: Swift answer to this question is to use the doubleValue property to access the slider value in OSX: slider.doubleValue = 0.1 print(slider.doubleValue) 来源: https://stackoverflow.com/questions/9867343/change-nsslider-value-programmatically

Determine when NSSlider knob is 'let go' in continuous mode

大城市里の小女人 提交于 2019-12-18 04:34:08
问题 I'm using an NSSlider control, and I've configured it to use continuous mode so that I can continually update an NSTextField with the current value of the slider while the user is sliding it around. The issue I have is that I don't want to 'commit' the value until the user lets go of the knob, i.e I don't want my application to take account of the value unless the user lets go of the slider to signify it's at the desired value. At the moment, I have no way of knowing when that's the case; the

How to update NSImageView using NSSlider?

淺唱寂寞╮ 提交于 2019-12-13 09:25:14
问题 I have an NSSlider in FirstViewController . I have 12 NSImageViews in SecondViewController . I'd like to move a slider in first window and shuffle images in these 12 views in second window. How to update these NSImageViews every time when moving the slider? SecondViewController var imagesQty = 100 override func viewWillAppear() { super.viewWillAppear() //let arrayOfViews: [NSImageView] = [view01,...view12] for view in arrayOfViews { let i = Int(arc4random_uniform(UInt32(imagesQty-1))) let

Best strategy to handle incoming midi signal from MIDIReadProc in cocoa

限于喜欢 提交于 2019-12-11 02:45:07
问题 I have to move some NSSlider by hardware midi controller, I have programmed a midi learn procedure to assign hardware cursor to NSSlider (sub class of), and up there it's all right. Inside MIDIReadProc , I handle moving NSSlider wich depends from incoming control and value, but now when I move hardware cursor, Sliders can be move one for time, it is like moving cursor stop the others. My question is, what is best strategy to handle cursor moving concurrently ? 1 . Should I have to handle with

How can NSSlider be customised to provide a non-linear scale in cocoa?

拟墨画扇 提交于 2019-12-09 12:41:14
问题 How can NSSlider be customised to provide a non-linear scale in cocoa? i.e - 0, 2, 4, 6, 10. With the slider constrained to stopping on tick marks only, I want the slider to stop on 0, 2, 4, 6, 10 (and not 8 for instance). Thanks. 回答1: Quickly written example based on an array with the desired values: SampleAppDelegate.h #import <Cocoa/Cocoa.h> @interface SampleAppDelegate : NSObject <NSApplicationDelegate> { NSWindow * window; NSArray * values; IBOutlet NSSlider * theSlider; IBOutlet

custom NSSliderCell

一个人想着一个人 提交于 2019-12-08 23:11:22
问题 I've sort of accomplised implementing a custom slider cell that can draw over using images for the scroll bar and knob. The only obstacle that is in the way now is this, when I drag the knob quickly, the images get messed up. I've posted a screen shot. Here is the code: #import "customSliderCell.h" @implementation customSliderCell - (void)drawKnob:(NSRect)knobRect { NSImage * knob = knobImage; [[self controlView] lockFocus]; [knob compositeToPoint:NSMakePoint(knobRect.origin.x,knobRect.origin

How to create a custom NSSlider with a transparent middle bar and custom knob size

末鹿安然 提交于 2019-12-08 09:39:59
问题 I've searched around for some code on NSSliderCell but I can't find a way to do what I'm looking for. I'd like to create something like this (where the white line is the slider knob, 1 pixel width): I'm going to use this for the time bar of a music track, so it's going to move every second (that's why I want to use a NSSlider to make things easy). What do I need to do to make a slider, with a transparent middle bar, similar to the image above? PS: It's not going to be touchable, it's just for

How to customize a NSSlider

£可爱£侵袭症+ 提交于 2019-12-08 01:59:41
问题 I'm trying to implement a custom slider in Cocoa with 5 values. See my demo project, which can be downloaded here: http://s000.tinyupload.com/index.php?file_id=07311576247413689572. I've subclassed the NSSliderCell and implemented methods like drawKnob:(NSRect)knobRect and drawBarInside:(NSRect)cellFrame flipped:(BOOL)flipped etc. I'm facing some issues: I'm not able to position the knob correctly regarding to the background image. I know that I'm able to change the knob's frame, and I've