Thingworx Mashup to Vuforia Toggle Button
Hi,
I am looking at ways to achieving the following :
I have a toggle button in Vuforia, which needs to be 'Clicked' from Thingworx Service.
How can this be achieved?
Avinash
Hi,
I am looking at ways to achieving the following :
I have a toggle button in Vuforia, which needs to be 'Clicked' from Thingworx Service.
How can this be achieved?
Avinash
The option 2 I tried something like:
twx.app.fn.triggerStudioEvent(document.querySelector('[widget-id="toggle-1"]'), 'click');
$scope.$applyAsync();
// or
twx.app.fn.triggerStudioEvent(document.querySelector('[widget-id="toggle-1"]'), 'app.view["Home"].wdg["toggle-1"].svc.click');
$scope.$applyAsync();
but it does not work, need to check more detailed why is not working...
But ... what are the benefits to have the option 2.)
Because when the change the value of the toggle widget e.g. :
$scope.setWidgetProp('toggle-1','value',!$scope.getWidgetProp('toggle-1','value'));
$scope.app.view.Home.wdg['toggle-1'].value=true;// or !$scope.app.view.Home.wdg['toggle-1'].value
$scope.$applyAsync();//to force
// or better this below
$scope.setWidgetProp('toggle-1','value',!$scope.getWidgetProp('toggle-1','value'));
twx.app.fn.triggerStudioEvent(document.querySelector('[widget-id="toggle-1"]'), 'click');
$scope.$applyAsync();//to force the execution
This will change the value of the toggle widget ( value = !value to change it)
And the triggerStudioEvent will call the click event and respectively if there is a callback function
If you want to involve this call from a External Data /twx value - you can bind this value e.g. to an parameter and then call the mentioned call from a $watch consturct e.g.
$scope.$watch('app.params.TWX_VALUE', function (newValue, oldValue, scope) {
if ( newValues != undefined) {
//possibly we need to convert the string to boolean value
var boolValue = newValues.toLowerCase() == 'true' ? true : false;
$scope.setWidgetProp('toggle-1','value',boolValue);
twx.app.fn.triggerStudioEvent(document.querySelector('[widget-id="toggle-1"]'), 'click');
$scope.$applyAsync();}
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.