Sie sind nicht angemeldet.

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

1

Dienstag, 10. Februar 2015, 19:43

How do you find mouse position within a container?

Say you click inside a container and want to know the mouse.x position within the container -- how many pixels from the left edge of the container the click point is. Is there an easy way to do this if the container is a child of another container which itself is the child of another container and so on?

The problem: Mouse.x it the mouse's offset from the left edge of the stage. Say you click inside container1. If the container sits on the stage then container1.x is its offset from the left side of the stage. You can simply subtract container1.x from mouse.x and know how far inside container1 the mouse is. But if container1 sits inside container2 then container1.x is only the offset from the left edge of container2.x. Not very helpful. One way to handle this with HTML elements using javascript is to set up a loop adding each div's (container's) offset to its parent then to its parent until you get to the top level div. I suspect you could do the same in KRPano but I'm betting there is a much easier way.

Is there???

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

2

Dienstag, 10. Februar 2015, 19:59

Maybe this would be of some help? http://krpano.com/docu/actions/#screentolayer
Regards,

Alexey

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

3

Dienstag, 10. Februar 2015, 21:00

Sweet! If only it were accurate....

Thanks Alexey!

Screentolayer would seem to be exactly what I'm looking for. Unfortunately it doesn't seem to be real accurate.

Example. I have a container with a width of 140px inside another container. If I click on leftmost edge I can't get a x value of less than 4. On the right most edge I get an x value of 151. Not that helpful. Is it a bug or is there some special trick to getting precision?

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

4

Mittwoch, 11. Februar 2015, 20:04

Quick update

The reason screentolayer gave inaccurate results was a bug. If the container has a border it throws off the results. See This thread.

Unfortunately the technique of adding each parent's x value to arrive at a stage offset doesn't work (easily at least) unless each container is left aligned. I really hope Klaus fixes screentolayer soon.

5

Dienstag, 17. Februar 2015, 01:00

Hi! I believe this is exactly what you need: http://krpano.com/plugins/userplugins/abs/ (made by yours truly).



My Krpano plugins: Auto Thumbs - Tooltip - Abs

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

6

Sonntag, 22. Februar 2015, 00:53

Thanks Hernán, but I don't think that is what I'm after. I need mouse x/y relative to the layer. Check out This thread for an example.

7

Sonntag, 22. Februar 2015, 22:56

I'm sorry I didn't read everything thoroughly. I now see that the new layertoscreen action provides the same function as my plugin.

What I meant was that you could use it to do it the way you said, to get the container x and then subtract it from mouse.x. Could you solve the problem then?
My Krpano plugins: Auto Thumbs - Tooltip - Abs

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

8

Montag, 23. Februar 2015, 17:28

Could you solve the problem then?

Yes, as described in that other thread.