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

Friday, January 9th 2009, 10:17am

get mouse position

i need to get mouse position coordinates x and y relative to display. for example x 40px y 20 px from lefttop, via javascript.
As this example "var hlookat = Number( krpano().get("view.hlookat") );" i try with something as.. "var mouse = Number( krpano().get("control.xxxx") );"
but in the documentation there is nothing about position . could some one help me? thank you.

2

Saturday, January 10th 2009, 6:38pm

Hi,

getting the current mouse screen position is currently not possible via the get-interface,
maybe in one of the next version,

but note - the flash <-> javascript interface is slow!
it shouldn't be used high-frequently (for example for mouse position checking)

what do you want to do with the mouse position?
mabe it could be done also in a other way...

best regards,
Klaus

3

Monday, January 12th 2009, 11:23am

i need it to prepare a tool to easy have the position in pixel over the viewer and place plug in as buttons, hotspot map and any others image i need to place.

4

Monday, January 12th 2009, 11:31am

error in documentation

i spend a lot of time to try as in documentation js/javascript xml file: .... on click="js(jstest, hello from xml)" is wrong - correct is on click="js(jstest(hellofrom xml))" to send params via javascript..

5

Tuesday, January 13th 2009, 11:17am

Hi,

you're right!
sorry, I mixed up something in the js() documentation.

I have updated the documenation now:
http://krpano.com/docu/actions/#js


about the mouse position - here is a very small plugin, that's let you access the mouse position:
jsmouse.zip
(flash source code also included)

include this plugin in the xml with:

Source code

1
<plugin url="jsmouse.swf" />


then from javascript you can get the current mouse position with:

Source code

1
2
3
var krpano = document.getElementById("krpanoSWFObject");
var mousex  = krpano.get("mouse.x");
var mousey  = krpano.get("mouse.y");


here is the flash source of this plugin for better understanding:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import krpano_as3_interface;

    public class jsmouse extends Sprite
    {
        private var krpano : krpano_as3_interface = null;
        private var mouse  : mousetool            = null;
        
        public function jsmouse()
        {
            krpano = krpano_as3_interface.getInstance();
            
            if ( krpano.get("version") < "1.0.7" )
            {
                krpano.call("error(jsmouse plugin - wrong krpano version! 1.0.7 or higher needed);");
                return;
            }
            
            this.addEventListener(Event.ADDED_TO_STAGE, startplugin);
        }
        
        public function startplugin(evt:Event):void
        {
            mouse = new mousetool();
            mouse.stage = this.stage;
            
            // register/link <mouse> node
            krpano.set("mouse", mouse);
        }
    }
}

import flash.display.Stage;

class mousetool
{
    public var stage:Stage;

    public function get x():Number
    {
        return stage.mouseX;
    }
    
    public function get y():Number
    {
        return stage.mouseY;
    }
}


best regards,
Klaus

6

Thursday, January 22nd 2009, 3:28pm

very very strange problem krpano().call is not a function

thank you for your attention and fast solution.
I have now a very strange problem.
i'm trying your example of javascript functions. it run perfect in 2 computers and and on a mac. but in others 2 computers i have this message:

"krpano().call is not a function
file:///C:/Documents%20and%20Settings/User/Desktop/vacanzemare/giardini/index_tool.html#
Line 187"

same files, same folders, same 1.0.8 swf... same!
do you think somethink about it?
Thank you again.

7

Thursday, January 22nd 2009, 3:51pm

Hi,

note - when running it locally the flash security settings must be adopted for a working javascript interface,
see here:
http://krpano.com/docu/localaccess/

best regards,
Klaus

8

Thursday, January 22nd 2009, 4:56pm

security

i think is not that problem i see the panos and the actions and function inside xml files are running. just javascript don't run.
it seem that the first command :
"function krpano()
{
return document.getElementById("krpanoSWFObject");
}"
is wrong or not read so the message is krpano().call is not a function.

i also change it in
var krpano=
document.getElementById("krpanoSWFObject");
and done the correction krpano.call .. it run in the same computer and not in the others two.

very very strange. only 2 computers. with ff3 and ie7 i tryed to change flash version 9 - 10 reinstall ff3 .. nothing.

and obviusly i must work on that 2 computers.... *cursing*

thank again for help .

Suggestion: is possible to create an attribute as <group name="xxxx"> plugin1,plugin2,plugin3,....</group>
so with only a set will be possible change parameters of a group of plugins ex: set(group[xxxx].visible,false) l

9

Thursday, January 22nd 2009, 9:31pm

Hi,

yes, the security settings affect only "Javascript" and "plugins with webaccess" like the Googlemaps plugins!
everything else will work normally,

or - try the same example on a server, then there should be a problem

Quoted

Suggestion: is possible to create an attribute as <group name="xxxx"> plugin1,plugin2,plugin3,....</group>
so with only a set will be possible change parameters of a group of plugins ex: set(group[xxxx].visible,false) l
I will think about such, at the moment it's only possible to hide all plugins/hotspot at once via
"hotspot.visible" and "plugin.visible"

best regards,
Klaus

10

Monday, August 23rd 2010, 1:10pm

mouse position in javascript


about the mouse position - here is a very small plugin, that's let you access the mouse position:
index.php?page=Attachment&attachmentID=15
(flash source code also included)

Hello

I am using jsmouse with some php scripts to add hotspots to database and later generate panorama's xml.

I set lookat_interval = setInterval( 'getlookat()',1000 ); to see what happen and i can't get javascript to read only the position which i need. If i move mouse out of preview position is still updatep.

so.. is there any method to get the position after mouse click ? (not instantly).

11

Monday, August 23rd 2010, 1:31pm

Hi,

you could call a own javascript function on click from the xml,

e.g.
xml:

Source code

1
<events onclick="js( krpano_mouseclick() );" />


html/js:

Source code

1
2
3
4
function krpano_mouseclick()
{
 ...
}


best regards,
Klaus

Destiny

Trainee

Posts: 61

Location: Australia

Occupation: Primary School Teacher and Freelance Photographer

  • Send private message

12

Friday, February 1st 2013, 7:37am

I am a bit slow on the uptake.. *cry*

I do not know if I have done this right..

I am trying to use kolor ptp to achieve a mouse xy location reference by clicking anywhere on the pano to get the exact location to place a hotspot goto button etc..

looks like this thread is a bit old but better late than never.. *rolleyes*

I have downloaded the plugin and added that to my xml..

I have also placed the js into my html page and tried it in the head and body... But.... *blink*

So.. what am I doing wrong.. I have used the krpano update tool to update my files.

Destiny..


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Virtual Tour generated by Panotour</title>
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<style type="text/css">
@media only screen and (min-device-width: 800px) { html { overflow:hidden; } }
* { padding: 0; margin: 0; }
html { height: 100%; }
body { height: 100%; overflow:hidden; }
#container { height: 100%; min-height: 100%; width: 100%; margin: 0 auto; }
</style>

<script>
var krpano = document.getElementById("krpanoSWFObject");
var mousex = krpano.get("mouse.x");
var mousey = krpano.get("mouse.y");
</script>

</head>
<body>


<script src="swfobject/swfkrpano.js"></script>
<div id="container">
<div id="panoDIV" style="height:100%;">
<script>
embedpano({target:"panoDIV",swf:"virtualtour.swf"});
</script>
<noscript>
<div id="tour">
<object width="100%" height="100%">
<embed src="virtualtour.swf" width="100%" height="100%" allowFullScreen="true"></embed>
</object>
</div>
</noscript>
</div>
</div>
</body>
</html>
Sometimes I might come across as being stupid; But I have an IQ of 137 *tongue*

13

Tuesday, February 5th 2013, 12:31pm

Hi,
looks like this thread is a bit old but better late than never..
Yes, this thread is really old and very-outdated!

You don't need any external Javascript or plugin for this.

There are the mouse.x, mouse.y variables:
http://krpano.com/docu/actions/#mouse.x
to get the 2d screen position of the mouse,

and there are is the screentosphere() action to convert screen positions to spherical coordinates:
http://krpano.com/docu/actions/#screentosphere


Providing an exact usage example would presume to know what you are trying to do...
but maybe have also a look into the examples from the krpano viewer download package,
e.g. these ones:
http://krpano.com/examples/10815/example…se/jsmouse.html
http://krpano.com/examples/10815/example…e-hotspots.html

Best regards,
Klaus

Destiny

Trainee

Posts: 61

Location: Australia

Occupation: Primary School Teacher and Freelance Photographer

  • Send private message

14

Thursday, February 7th 2013, 11:42am

Oh Klaus.. I really want to marry your brain.. You are just amazing for sure.. *g* You make things look so easy yet I burn my brain cells up trying to work out simple stuff.. *cry*

This url here is the exciting one.. http://krpano.com/examples/10815/example…e-hotspots.html

I think Its giving me what I am looking for but... I will be picking your brain more on this.. *thumbsup*

Destiny...
Sometimes I might come across as being stupid; But I have an IQ of 137 *tongue*

Destiny

Trainee

Posts: 61

Location: Australia

Occupation: Primary School Teacher and Freelance Photographer

  • Send private message

15

Thursday, February 7th 2013, 11:07pm

Dear Klaus

It has just become apparent to me that I am unable to interact with this krpano test.. http://krpano.com/examples/10812/example…se/jsmouse.html The coordinates move but not the pano....

Others can pan the pano using Windows with different browsers.. I am using a Mac with Safari but it will not rotate.. I tried it with Opera and it works fine... Since it did not pano I was under the impression that it did not until I was made aware something was wrong..

Thank you

Destiny..
Sometimes I might come across as being stupid; But I have an IQ of 137 *tongue*

16

Monday, September 2nd 2013, 11:54pm

Ich habe die Anweisungen befolgt, sehe aber keine Koordinaten-Anzeige.

Ich habe die jsmouse.swf in den vtour-Ordner (enthält die tour-xml) kopiert und die Zeile <plugin url="jsmouse.swf" /> in die tour.xml eingefügt.

Was muss ich noch machen, um die Koordinaten zu sehen?

Grüße

Panox

17

Tuesday, September 3rd 2013, 9:19am

Hi,

auf welche Anweisungen beziehst du dich und wo soll die Anzeige in deinem Fall erfolgen?
In dem 'jsmouse' Beispiel wird die Maus-Position ja nur per Javascript ausgelesen und auf der HTML Seite selbst angezeigt.

Bzgl. 'jsmouse.swf' - das Plugin ist nicht notwendig, krpano hat seit ein paar Jahren die mouse.* Variablen direkt integriert.

Schöne Grüße,
Klaus

Similar threads