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:

    Code
    <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

  • 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

  • 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:

    Code
    <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.

  • 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

  • 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

  • *smile* Thank you David... I am not such great coder as you say *wink* 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...

    Quote

    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 *wink* ) --- Long life David. *thumbsup*

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!