You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, May 28th 2018, 3:45pm

Double click in Hotspot [SOLVED]

Hello, I need some guidance in krpano JS.

I have an action and a style that defines the behaviour of double clicking hotspots. When I load my hotspots from server and inject them in XML it works as expected. But when I try to add hotspots dynamically via Javascript I can't get it to work.

This is the Style tag for the doubleclick event

Source code

1
<style name="doubleclick" downx="0" downy="0" clicks="0" onsingleclick="" ondoubleclick="" onclick="doubleclick_style_onclick();" />


This is the action

Source code

1
<action name="doubleclick_style_onclick"> inc(clicks); if(clicks == 2, set(clicks,0);  stopdelayedcall(doubleclickdetector); if((((mouse.x-downx)^2 + (mouse.y-downy)^2)^0.5) LT (device.touch ? 10 : 2), ondoubleclick(); , onsingleclick(); onsingleclick(); ); , copy(downx, mouse.x);  copy(downy, mouse.y); delayedcall(doubleclickdetector, 0.3,  set(clicks,0);  onsingleclick(); ); ); </action>


And this is how I am trying to set the events in JS



Source code

1
2
3
4
5
      krpano.call('addhotspot('+$('#named').val()+')');
      krpano.call('hotspot['+$('#named').val()+'].loadstyle("doubleclick");');
      krpano.call('set(hotspot['+$('#named').val()+'].url, "/img/tools/hotspotNav.png");');
      krpano.call('set(hotspot['+$('#named').val()+'].ondoubleclick,js(functions.gotToScene('+$('#named').val()+')));');
      krpano.call('set(hotspot['+$('#named').val()+'].onsingleclick,js(functions.editHotspotNav('+$('#named').val()+')));');


What happens in this code is: only single click works.
When double clicked, nothing happens...
But if I comment the single click line, then double click function is called

--- EDIT

Managed to work...

Instead of calling the onsingleclick and ondoubleclick attributes in set function of krpano.call, I did this:

Source code

1
2
3
4
5
6
for(var i = 0; i < hotspotArr.length; i++){
                    if(hotspotArr[i].name.toLowerCase() == $('#named').val().toLowerCase()) {
                        $(hotspotArr[i]).attr('ondoubleclick', 'js(functions.gotToScene('+$('#named').val()+'));');
                        $(hotspotArr[i]).attr('onsingleclick', 'js(functions.editHotspotNav('+$('#named').val()+'));');
                    }
                }


Now it works as expected

This post has been edited 1 times, last edit by "insideplaces" (May 28th 2018, 5:00pm)


2

Monday, May 28th 2018, 4:57pm

take a look there ;)

#mce_temp_url#


"Event" maybe can help you