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.

  • "FlashinnaPano" started this thread

Posts: 29

Location: Orygun, USA

  • Send private message

1

Wednesday, February 3rd 2010, 2:40am

ifnot -- Any better way?

Hello,
I've ended up with a ridiculous nest of ifnot statements and am curious if there might be a cleaner solution.

Here's the relevant bit of xml:

Source code

1
2
3
4
5
6
7
	<plugin name="dock"
[...]
        onloaded="delayedcall(5,ifnot(hovering,action(hideDock)));"
        onover="action(showDock);"
        onhover=""
        onout="delayedcall(1,ifnot(hovering,ifnot(plugin[Button1].hovering,ifnot(plugin[Button2].hovering,ifnot(plugin[Button3].hovering,action(hideDock))))));"
        ondown=""

The dock plugin delimits an area containing buttons/controls. The behavior is simple: briefly show the area/buttons when loaded and then hide if the cursor is elsewhere. Show on mouse over. When mouse out wait briefly to account for mousing errors around edges before hiding.

The onout statement is getting very messy because of the delayedcall and the necessity of using infnots for each button. I was curious if there isn't a better, more human-readable way than what I have above?

I have more buttons than just the three in this snippet.

When I omit the ifnot statements for each button and move the cursor over the button, the hideDock action fires, but because each button contains onover="action(showDock);" the dock comes back again, which causes everything to oscilate in and out.

It would be much easier were it possible to just check if the cursor was not over any object.

Any nudges towards clarity would be appreciated.

I've also noticed an inconsistency in the way my hideDock action behaves. From onloaded, one of the buttons does not move offscreen and just fades away, but from onout it moves offscreen as it should. There's nothing in the xml that I can find to account for the difference.

Thanks
Joe

Tourvista

Intermediate

Posts: 259

Location: Leicester UK

  • Send private message

2

Wednesday, February 3rd 2010, 6:40pm

Hi FlashinnaPano!

Do you have a link to see it live? Your explanation is ok but test it and have access to the whole code would be very helpful.

Some weeks ago I had a very similar problem:

EXAMPLE

Every single hotspot is actually two hotspots superposed. One for the the black rectangle plus the red button, and the other for the text. When I set up an 'onout' action to both of them it went crazy. My solution was to add a third invisible plugin on top of them, which contained the 'onhover' and 'onout' actions.

When I say invisible plugin I mean visible="true" alpha="0.1". I tried alpha="0" but the mouse events weren't very consistent.

I am not very familiar with the 'ifnot' command, but I fount extremely useful to create the plugins using actions and the 'addplugin' command.

Cheers

Rafael

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

3

Wednesday, February 3rd 2010, 8:13pm

Hi Joe,

Take a look at this post from Klaus: There is a mode to remove/stop a Delayedcall?

So, perhaps, a possible code would be:

Source code

1
2
3
4
5
6
7
<plugin name="dock"
[...]
    	onloaded="set(delayedcallkilled,false);delayedcall(5,if(delayedcallkilled == false,action(hideDock)));"
    	onover="set(delayedcallkilled,true);action(showDock);"
    	onhover=""
    	onout="set(delayedcallkilled,false);delayedcall(1,if(delayedcallkilled == false,action(hideDock)));"
    	ondown=""

As Tourvista already said, a link to see it live would be useful...

SAlut.

  • "FlashinnaPano" started this thread

Posts: 29

Location: Orygun, USA

  • Send private message

4

Thursday, February 4th 2010, 4:37am

Hello,
Take a look at this post from Klaus: There is a mode to remove/stop a Delayedcall?

So, perhaps, a possible code would be:

Aha! Your solution using delaycallkilled is perfect! Thank you.

My problem isn't quite as complex as Rafael's. I really like the hotspot behavior and control layout on Tourvista; all with a rainbow, too! Excellent!

I have never written any sort of script or code with 8 levels of parentheses. That sort of obfuscation is too much and I thought there must be a better way that I am missing; easy to do at my very low level of krpano experience.

My learning now is very much trial and error with heavy emphasis on the error part. Sometimes when I get stuck, I ask a foolish question or one like this where I find out about krpano's secret sauce like delaycallkilled, which I can't find documented anywhere.

I didn't provide a link because what I have now is a somewhat messy prototype that I'm using to learn krpano. If needed, I would be happy to provide a link in private email.

Thanks,
Joe

5

Friday, February 5th 2010, 8:23pm

Michel, what a great coder are you. One more problem killed.

I used to read every of your post cause there is a ton of usefull info in. Some times I don't use them imediatly but I know one day they will be usefull.

Long life man.

David
Istanbul virtual tour creation : www.vizyon360.com

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

6

Sunday, February 7th 2010, 5:24am

*smile* Thank you David... I am not such great coder as you say ;-) I am just a Krpano enthusiast as many others here *rolleyes* . I have some very basic programming knowledge so sure many of my answers are not so correct as they should to be...

Quoted

I used to read every of your post cause there is a ton of usefull info in. Some times I don't use them imediatly but I know one day they will be usefull.
*smile* The requests from the members are also really usefull to learn how Krpano works... I learn a lot from those requests, in trying to find an answer....

"size uzun ömür" (hope is correct ;-) ) --- Long life David. *thumbsup*