nsslider

How can I get the value of an NSSlider continuously?

只谈情不闲聊 提交于 2019-12-06 16:44:42
问题 It seems like NSSlider in Cocoa does not provide a delegate to receive an event like Value Changed for a UISlider . How can I get the value of an NSSlider continuously and display it in an NSTextField , for example? 回答1: You need to research Cocoa's Target/Action mechanism. This is a basic Cocoa concept you'll need to understand. The slider (and any other control) can be given a target (some controller object) and an action (the method to call against that controller object). The action is

How to customize a NSSlider

孤街醉人 提交于 2019-12-06 11:49:05
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 tried doing some calculation to position the knob correctly, but I'm not able to make it work for my

NSUndoManager: redo not working

孤街浪徒 提交于 2019-12-06 01:47:22
问题 I am making a simple application that uses a NSSlider, which can be put to it's max or min value with two buttons.The undo manager shall track all changes and allow to undo/redo all changes made using these two buttons. Here is the interface: #import <Cocoa/Cocoa.h> @interface AppDelegate : NSObject <NSApplicationDelegate> { @private NSUndoManager* undoManager; } @property (assign) IBOutlet NSWindow *window; @property (weak) IBOutlet NSSlider *slider; - (IBAction)putToMax:(id)sender; -

Subclassing NSSlider: Need a workaround for missing mouse up events (Cocoa OSX)

三世轮回 提交于 2019-12-06 01:39:53
问题 I am trying to subclass NSSlider to create a control called a jog dial. Basically what I need is a slider which always starts at the middle and when it is moved to the left or right it will send notifications every so often (determined by an attribute one can set) informing its container of its current value, then when you let you go of the knob, it will return to the middle. I was hoping to implement the functionality to return the slider to the middle and stop sending notifications in the

How can I get the value of an NSSlider continuously?

馋奶兔 提交于 2019-12-04 22:19:36
It seems like NSSlider in Cocoa does not provide a delegate to receive an event like Value Changed for a UISlider . How can I get the value of an NSSlider continuously and display it in an NSTextField , for example? You need to research Cocoa's Target/Action mechanism . This is a basic Cocoa concept you'll need to understand. The slider (and any other control) can be given a target (some controller object) and an action (the method to call against that controller object). The action is fired when the user stops dragging by default. Check the slider's Continuous property in Interface Builder to

NSUndoManager: redo not working

北城余情 提交于 2019-12-04 07:22:00
I am making a simple application that uses a NSSlider, which can be put to it's max or min value with two buttons.The undo manager shall track all changes and allow to undo/redo all changes made using these two buttons. Here is the interface: #import <Cocoa/Cocoa.h> @interface AppDelegate : NSObject <NSApplicationDelegate> { @private NSUndoManager* undoManager; } @property (assign) IBOutlet NSWindow *window; @property (weak) IBOutlet NSSlider *slider; - (IBAction)putToMax:(id)sender; - (IBAction)putToMin:(id)sender; - (void) setSliderValue: (float) value; @end Implementation: #import

Subclassing NSSlider: Need a workaround for missing mouse up events (Cocoa OSX)

家住魔仙堡 提交于 2019-12-04 05:27:52
I am trying to subclass NSSlider to create a control called a jog dial. Basically what I need is a slider which always starts at the middle and when it is moved to the left or right it will send notifications every so often (determined by an attribute one can set) informing its container of its current value, then when you let you go of the knob, it will return to the middle. I was hoping to implement the functionality to return the slider to the middle and stop sending notifications in the mouseUp event of the slider but it seems that for some reason apple disables the MouseUp event after a

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

南楼画角 提交于 2019-12-03 14:59:46
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. 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 NSTextField * theLabel; } - (IBAction)sliderChanged:(id)sender; @property (assign) IBOutlet NSWindow *window; @end

NSSlider animation

ⅰ亾dé卋堺 提交于 2019-11-30 14:18:36
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. 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 we have to resort instead to manually animating slider value. Since we're doing this on a Mac - you can use

change NSSlider Value programmatically

喜夏-厌秋 提交于 2019-11-29 10:00:33
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! You can use the methods of NSControl. Example: [self.slider setDoubleValue:0.1]; 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