cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Switching the click function of a button

Highlighted
Amethyst

Switching the click function of a button

I'm trying to switch the function of a button after click. In effect making the button toggle between, hiding and showing a number of widgets.

 

I tried setting the click function of the button to a function:

tutorialShow();

And within that function is a line:

$scope.setWidgetProp(button-1,'click', tutorialHide());

 

It's not working currently, how do I fix this code, or is there another method of achieving this?

Tags (1)
2 REPLIES 2
Highlighted

Re: Switching the click function of a button

I've done something along these lines with a HoloLens project to make a 3D Image widget behave like a toggle button.  In my case, I just use the click action to call a function and that function is a toggle, depending on the viability of some item.  So in the example below, I'm using gauge-1 to determine the visibility of the items, so I"m assuming they should all be the same.

 

$scope.gaugetoggle = function (){
   if ($scope.view.wdg['3DGauge-1']['visible']) {
       $scope.view.wdg['3DGauge-1']['visible'] = false;
       $scope.view.wdg['3DGauge-2']['visible'] = false;
       $scope.view.wdg['button-1']['text'] = 'Show';
}
  else {
      $scope.view.wdg['3DGauge-1']['visible'] = true;
      $scope.view.wdg['3DGauge-2']['visible'] = true;
     $scope.view.wdg['button-1']['text'] = 'Hide';

  }
}

Highlighted

Re: Switching the click function of a button

Hi @micah ,

as mentioned by @AllanThompson  you can use for the click the UI box event.

I want to point that this:

 

$scope.setWidgetProp(button-1,'click', tutorialHide());

 

- unfortunately it does not make sense here 

You can not set a function to a property!  The click is an event. But the setWidgetProp will set only properties. So you need to define it as listener.

The question is why do you want to perform such call. Another option is that you can use the UI event box to set the function. If you want to set some function dynamically to an element on run time. In this case you set in UI click event box for the  function to app.myClickFunction();

and in Js use some definition like this:

 

$scope.myCurrentFunction ="tutorialHide()"
...
$scope.app.myClickFunction() {
eval($scope.myCurrentFunction);
}

 

 

Announcements
Join an
AR Working Group!

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection