Forum Discussion
MIkeMunger
8 years agoCommunity Member
How to Detect Mouse Button Down and Mouse Button Up Events
I would like to be able to detect mouse down and mouse up events. Want to determine if a user pressed a control and held it down for 3 seconds before releasing the control. On the surface the exis...
Learn-Primeast
7 years agoCommunity Member
I know this is an old thread, but hopefully this is helpful to someone. It is possible to detect a mouse 'click' or a 'mousedown' or any other DOM event using Javascript. In the example below I asked the module to listen out for 'mousedown' and if the target was the scrollbar then some variable in Storyline is adjusted.
document.addEventListener('mousedown', function(e) {
let myClass = e.target.className;
//console.log(myClass);
if (myClass === 'scrollarea-btn') {
var player = GetPlayer();
player.SetVar("monitor_panel_click",true);
}
});
- StefanKoler-9fd3 years agoCommunity Member
Hi Simon,
I am also looking for a solution for "Mouse Button up", so that some event is triggered when the mouse button is release while the mouse is positioned over a specific object.
I guess the JS should look like below. But what I don't understand: How do I figure out what class my object is?
It is not the name of my object, or is it? I tried using that in the attached test project.document.addEventListener('mouseup', function(e) {
let myClass = e.target.className;
//console.log(myClass);
if (myClass === 'scrollarea-btn') {
var player = GetPlayer();
player.SetVar("monitor_panel_click",true);
}
});
Related Content
- 3 months ago
- 7 months ago
- 4 months ago