Hotspot Javascript and onclick function triggering?

Special forum to share and discuss skins for Pano2VR and Object2VR
Post Reply
jpatten
Posts: 5
Joined: Thu Feb 02, 2017 2:01 pm
Location: Modesto, California
Contact:

Hi all,

I’m trying to trigger a javascript function in a pano with a hotspot. The javascript function triggers a handler outside of the vr in a LiveCode project.

I am not a javascript programmer and have a very basic understanding of javascript.

I started by getting some basic javascript working by using the Pano2VR javascript api. I used: javascript:pano.enterFullscreen() in a hotspot and it worked great.

Now I want to trigger a function via an addListener event. Here is what I have:

I have created a skin for a hotspot and selected Go to URL as the action and
javascript:pano.event.addListener('jp_hotspot','click', function() {liveCode.myLiveCodeHandler();}); as the text of my URL.

The panorama loads, but the expected click function is not occurring.

My example is based on a Google Maps example that triggers a javascript function when the user clicks on a map marker. The Google map example is: google.maps.event.addListener(marker, 'click', function() {
liveCode.myLiveCodeHandler();
});

The Google Maps example works in a browser object in a LiveCode (www.livecode.org) Project. The browser object in the LiveCode project consists of a Google Map with a map marker. Clicking the Google Map marker triggers the Javascript code that is then captures by the LiveCode project and executes the functions handler.

The ability to trigger a javascript function from the pano and then have LiveCode intercept and execute on that function, enables many more capabilities.

I guess my question is can a execute a javascript function, that is not part of the Pano2VR js api, from a hotspot action? And, what would the code look like to make that happen?

Thank you!

John Patten
SUSD
jpatten
Posts: 5
Joined: Thu Feb 02, 2017 2:01 pm
Location: Modesto, California
Contact:

Why does that answer always come to you after you post a cry for help?!! :)

I had:

pano.event.addListener('jp_hotspot','click', function() {liveCode.myLiveCodeHandler();});

which should have been:

window.addEventListener('click', function() {liveCode.myLiveCodeHandler();});

"pano." does not have an addEventListener defined for it. I think that was the reason why this was not working. I hadn't realized I could use document.addEventListerner, or window.addEventListener in the javascript of the skin.js. Chalk one up to inexperience with javascript.

Cheers!
User avatar
360Texas
Moderator
Posts: 3684
Joined: Sat Sep 09, 2006 6:06 pm
Location: Fort Worth, Texas USA
Contact:

I would add that to our "Lessons Learned Book". Good learning experience.

It is good :D to have a 'Moment of enlightenment"

Thank you for sharing.
Dave
Pano2VR Forum Global Moderator
Image
Visit 360texas.com
Post Reply