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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Click Event on Video Widget

mn1
14-Alexandrite
14-Alexandrite

Click Event on Video Widget

Hey there,

Is there a possiblity to catch the click event on a video widget? If I catch all click events how can i get the ID of the widget which is clicked?

Thanks for help.

ACCEPTED SOLUTION

Accepted Solutions
mn1
14-Alexandrite
14-Alexandrite
(To:mn1)

I solved the problem alreay by myself!

View solution in original post

6 REPLIES 6
mn1
14-Alexandrite
14-Alexandrite
(To:mn1)

I solved the problem alreay by myself!

What was your solution?

mn1
14-Alexandrite
14-Alexandrite
(To:ClayHelberg)

Hi,

I added an Event Handler:

window.addEventListener('click', $scope.Ausgabe);

and in the function Ausgabe I checked, if the click Event was sendet by a Video:

 

$scope.Ausgabe=function(){
console.log("A click event is recived");
if (window.event.path[0].tagName=='BUTTON'|| window.event.path[0].tagName=='IMG'){
console.log(window.event.path[2].attributes["0"].nodeValue); // if an image or button was clicked, this line prints the id
}
if (window.event.path[0].tagName=='VIDEO'){
console.log(window.event.path[3].attributes["0"].nodeValue); // If a video was clicked, this line prints the id

}

Excellent, thanks for the explanation.

Hi @ClayHelberg ,

 

here I want  to clarify it furhter based on my experience.

So in the @mn1 's example the solution is based on particular windget configuration and will not work and every project - so need adoption in particular situation . So I did an example and it the code was not working in this case. So to get it working I needed to go in chrome in the  console debugging  Strg -Shift -I and  do some thing like:

//////////////////////////////////////////////////////
document.addEventListener('click', function(event) {
console.log("click() 1 called");
                                          
 console.warn(event);                                                   
});

And then to check the console warning in the console window and to try to explore the current setting of the event object:

 

2019-02-21_16-53-20.gif

 

In my case for the video widget  the correct expression should be:

 

...
if (window.event.path[0].tagName=='VIDEO'){
console.log(window.event.path[0].attributes["0"].nodeValue);
 // If a video was clicked, this line prints the video source
console.log(window.event.path[3].attributes["0"].nodeValue);
// If a video was clicked, this line prints the video source
}
...

 

2019-02-21_16-53-50.gif

2019-02-21_17-06-37.gif

Thanks for the elaboration, @RolandRaytchev . That will be helpful info to file away for future reference.

Announcements

Top Tags