diff --git a/src/widget/widget.js b/src/widget/widget.js index 1523545..8e093c9 100644 --- a/src/widget/widget.js +++ b/src/widget/widget.js @@ -94,18 +94,20 @@ class Widget extends React.Component { }; } - inputDataChanged(widget, data, controlID, controlValue) { + inputDataChanged(widget, data, controlID, controlValue, isFinalChange) { // controlID is the path to the widget customProperty that is changed (for example 'value') // modify the widget customProperty if (controlID !== '') { let updatedWidget = JSON.parse(JSON.stringify(widget)); updatedWidget.customProperties[controlID] = controlValue; - AppDispatcher.dispatch({ - type: 'widgets/start-edit', - token: this.state.sessionToken, - data: updatedWidget - }); + if(isFinalChange) { + AppDispatcher.dispatch({ + type: 'widgets/start-edit', + token: this.state.sessionToken, + data: updatedWidget + }); + } } // The following assumes that a widget modifies/ uses exactly one signal @@ -185,21 +187,21 @@ class Widget extends React.Component { return this.inputDataChanged(widget, value, controlID, controlValue)} + onInputChanged={(value, controlID, controlValue, isFinalChange) => this.inputDataChanged(widget, value, controlID, controlValue, isFinalChange)} signals={this.state.signals} /> } else if (widget.type === 'NumberInput') { return this.inputDataChanged(widget, value, controlID, controlValue)} + onInputChanged={(value, controlID, controlValue, isFinalChange) => this.inputDataChanged(widget, value, controlID, controlValue, isFinalChange)} signals={this.state.signals} /> } else if (widget.type === 'Slider') { return this.inputDataChanged(widget, value, controlID, controlValue)} + onInputChanged={(value, controlID, controlValue, isFinalChange) => this.inputDataChanged(widget, value, controlID, controlValue, isFinalChange)} signals={this.state.signals} /> } else if (widget.type === 'Gauge') { diff --git a/src/widget/widgets/button.js b/src/widget/widgets/button.js index 897e1d9..f68144f 100644 --- a/src/widget/widgets/button.js +++ b/src/widget/widgets/button.js @@ -54,14 +54,14 @@ class WidgetButton extends Component { valueChanged(newValue, pressed) { if (this.props.onInputChanged) { - this.props.onInputChanged(newValue, 'pressed', pressed); + this.props.onInputChanged(newValue, 'pressed', pressed, true); } } render() { const buttonStyle = { - backgroundColor: this.props.widget.customProperties.background_color, + backgroundColor: this.props.widget.customProperties.background_color, borderColor: this.props.widget.customProperties.border_color, color: this.props.widget.customProperties.font_color, opacity: this.props.widget.customProperties.background_color_opacity diff --git a/src/widget/widgets/input.js b/src/widget/widgets/input.js index 21c0421..8d99564 100644 --- a/src/widget/widgets/input.js +++ b/src/widget/widgets/input.js @@ -73,7 +73,7 @@ class WidgetInput extends Component { valueChanged(newValue) { if (this.props.onInputChanged) { - this.props.onInputChanged(Number(newValue), 'value', Number(newValue)); + this.props.onInputChanged(Number(newValue), 'value', Number(newValue), true); } } diff --git a/src/widget/widgets/slider.js b/src/widget/widgets/slider.js index 23360d4..82b6926 100644 --- a/src/widget/widgets/slider.js +++ b/src/widget/widgets/slider.js @@ -79,14 +79,14 @@ class WidgetSlider extends Component { valueIsChanging(newValue) { this.props.widget.customProperties.value = newValue; if (this.props.widget.customProperties.continous_update) - this.valueChanged(newValue); + this.valueChanged(newValue, false); this.setState({ value: newValue }); } - valueChanged(newValue) { + valueChanged(newValue, isFinalChange) { if (this.props.onInputChanged) { - this.props.onInputChanged(newValue, 'value', newValue); + this.props.onInputChanged(newValue, 'value', newValue, isFinalChange); } } @@ -95,7 +95,7 @@ class WidgetSlider extends Component { let isVertical = this.props.widget.customProperties.orientation === WidgetSlider.OrientationTypes.VERTICAL.value; let fields = { name: this.props.widget.name, - control: this.valueIsChanging(v) } onAfterChange={ (v) => this.valueChanged(v) }/>, + control: this.valueIsChanging(v) } onAfterChange={ (v) => this.valueChanged(v, true) }/>, value: { format('.2f')(Number.parseFloat(this.state.value)) }, unit: { this.state.unit } }