Skip to content

Commit

Permalink
setValue() no longer broadcasts changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Frame committed Mar 21, 2014
1 parent 7b914b2 commit 5ba0bff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/HorizontalSlider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ ctx.registerWidget('HorizontalSlider', module.exports = InlineWidget.extend(func
if (offset < 0) offset = 0;
if (offset > rect.width) offset = rect.width;

self.setValue(self._offsetToValue(rect, offset));
self._setValue(self._offsetToValue(rect, offset));
self._broadcastChange();

}

Expand Down
3 changes: 2 additions & 1 deletion lib/Knob/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ ctx.registerWidget('Knob', module.exports = InlineWidget.extend(function(_sc, _s
delta = startY - evt.pageY;
}

self.setValue(startV + delta);
self._setValue(startV + delta);
self._broadcastChange();

},
mouseup: function(evt) {
Expand Down
11 changes: 8 additions & 3 deletions lib/Widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,30 @@ Widget.Features.mixins = function(ctor, mixinList) {

/*
* ValueWidget mixin denotes any widget that represents a value.
* This mixin requires that the implementing widget have the following:
* This mixin requires that the implementing widget have the following:
*
* _value => the widget's current value
* onChange => a signal for broadcasting changes
* onChange => a signal for broadcasting requested changes
*
* Additionally, the private _setValue() function may be overridden to
* apply custom transform/display update logic
*
* The onChange signal should only be emitted in response to user
* interaction with the widget, and not in response to external requests
* to change the widget's displayed value.
*/
Widget.registerMixin('ValueWidget', {
getValue: function() {
return this._value;
},

setValue: function(value) {
this._setValue(value) && this._broadcastChange();
return this._setValue(value);
},

_setValue: function(v) {
this._value = v;
return true;
},

_broadcastChange: function() {
Expand Down

0 comments on commit 5ba0bff

Please sign in to comment.