/
Slider_mac.js
53 lines (48 loc) · 1.5 KB
/
Slider_mac.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module.exports = (function() {
var Container = require('Container');
var $ = process.bridge.objc;
var util = require('Utilities');
/**
* @class Slider
* @description The slider control can be used to give the user an optional range to select.
* This has the visual appearance of a "scrubber". Changes to the value can be
* tracked with the 'click' event.
* @extends Control
*/
/**
* @new
* @memberof Slider
* @description Creates a new slider control.
*/
function Slider(properties, options, inherited) {
options = options || {};
this.nativeClass = this.nativeClass || $.NSSlider;
this.nativeViewClass = this.nativeViewClass || $.NSSlider;
Container.call(this, properties, options, inherited || true);
this.native('setMinValue', 0);
this.native('setMaxValue', 1);
this.native('setDoubleValue', 0);
util.setProperties(this, properties, inherited);
}
Slider.prototype = Object.create(Container.prototype);
Slider.prototype.constructor = Slider;
/**
* @member value
* @type {number}
* @memberof Slider
* @description Gets or sets the value of the slider. The value is in a range from 0 to 1.
* @default 0
*/
Object.defineProperty(Slider.prototype, 'value', {
get:function() { return this.native('doubleValue'); },
set:function(e) {
if (e > 1) {
e = 1;
} else if (e < 0) {
e = 0;
}
this.native('setDoubleValue', e);
}
});
return Slider;
})();