Add handling for "camera actions" 3rd checkbox state
This commit is contained in:
15
api.cpp
15
api.cpp
@@ -86,6 +86,9 @@ class Context {
|
|||||||
if (event_type == GP_EVENT_TIMEOUT) {
|
if (event_type == GP_EVENT_TIMEOUT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (event_type == GP_EVENT_UNKNOWN) {
|
||||||
|
EM_ASM({ console.log(UTF8ToString($0)); }, event_data.get());
|
||||||
|
}
|
||||||
had_events = true;
|
had_events = true;
|
||||||
}
|
}
|
||||||
return had_events;
|
return had_events;
|
||||||
@@ -240,7 +243,17 @@ class Context {
|
|||||||
}
|
}
|
||||||
case GP_WIDGET_TOGGLE: {
|
case GP_WIDGET_TOGGLE: {
|
||||||
result.set("type", "toggle");
|
result.set("type", "toggle");
|
||||||
result.set("value", GPP_CALL(int, gp_widget_get_value(widget, _)) != 0);
|
int value = GPP_CALL(int, gp_widget_get_value(widget, _));
|
||||||
|
// Note: explicitly not adding `value` for any other values
|
||||||
|
// (e.g. camera actions often would return 2 here...)
|
||||||
|
switch (value) {
|
||||||
|
case 0:
|
||||||
|
result.set("value", false);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
result.set("value", true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
15
ui/widget.js
15
ui/widget.js
@@ -27,12 +27,17 @@ export class Widget extends Component {
|
|||||||
if (this.state.inProgress && nextState.inProgress) {
|
if (this.state.inProgress && nextState.inProgress) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this.state.inProgress || nextState.inProgress) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let prevConfig = this.props.config;
|
||||||
|
let { config } = nextProps;
|
||||||
|
if (config.type === 'toggle' && config.value === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
this.state.inProgress ||
|
getValueForComparison(config) !== getValueForComparison(prevConfig) ||
|
||||||
nextState.inProgress ||
|
config.readonly !== prevConfig.readonly
|
||||||
getValueForComparison(this.props.config) !==
|
|
||||||
getValueForComparison(nextProps.config) ||
|
|
||||||
this.props.config.readonly !== nextProps.config.readonly
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user