Add handling for "camera actions" 3rd checkbox state

This commit is contained in:
Ingvar Stepanyan
2021-07-26 15:00:35 +00:00
parent 36ed35192c
commit 8f30a60c2e
2 changed files with 24 additions and 6 deletions

15
api.cpp
View File

@@ -86,6 +86,9 @@ class Context {
if (event_type == GP_EVENT_TIMEOUT) {
break;
}
if (event_type == GP_EVENT_UNKNOWN) {
EM_ASM({ console.log(UTF8ToString($0)); }, event_data.get());
}
had_events = true;
}
return had_events;
@@ -240,7 +243,17 @@ class Context {
}
case GP_WIDGET_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;
}

View File

@@ -27,12 +27,17 @@ export class Widget extends Component {
if (this.state.inProgress && nextState.inProgress) {
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 (
this.state.inProgress ||
nextState.inProgress ||
getValueForComparison(this.props.config) !==
getValueForComparison(nextProps.config) ||
this.props.config.readonly !== nextProps.config.readonly
getValueForComparison(config) !== getValueForComparison(prevConfig) ||
config.readonly !== prevConfig.readonly
);
}