CabMasterPro User Guide
In This Topic
    Sliders and Updatefolding
    In This Topic
    Slider controls in Friendly Pages can be set up to control lots of things, but sometimes we want a slider to control the folding up of an item. If the user is watching the item in a 3D view while it is folding, it is helpful to have good performance so the folding happens more smoothly. To achieve this, you can add a special action to the slider control's action field like this...

    _systemaction("UpdateFolding")
    When you do this, the slider picks up the presence of this system action and the updating of the variable enters a "stealth mode". Changing the variable then does not update the whole item... it is assumed that you are using the controlled variable directly in the 3D Transform folding controls for some sections of the item, and only the folding specifications are recalculated - nothing else. The item should still fully update when you stop moving the slider however. When there is no user activity, the system enters an idle loop and cleans up calculations that may be needed to restore consistency.

    Now things get more complicated if you are doing some intermediate calculations on the way to setting the 3D Transform angles. In that case, you have to be careful to also forcibly update any intermediate variables using a SetValue or SetFormula action.

    To illustrate... [This example is from the "POS Countertop C-FL-300"]

    Suppose we have a variable Xdeg which is set to some value based on the position of the slider, then used in a number of places to set the maximum fold angle...

    The slider itself and an edit box next to it both control the same variable, Xfoldsliderval, like this: Slider_eg1

    Here is what the two control look like in the friendly page:

    Slider_eg2

    Notice that the slider has this "stealth updating" property, because it has the _systemaction("UpdateFolding") action. This means that as you move the slider, it will update Xfoldsliderval and recalculate the folding for the item but nothing else. In this case, the folding of one of the sections makes use of a variable called Xdeg, like this...

    Slider_eg3

    So the problem is that if Xdeg is simply given a formula based on Xfoldsliderval, the position of the slider, then Xdeg will not update as the slider changes position.

    To make it update, we need to explicitly add another action to the slider. For this, we have defined XdegAct using this deferred formula..
    XdegAct String :SetValue("Xdef",if Between(Xfoldsliderval,50,65,0) then 90deg else 0deg)

    Note: This action sets Xdeg to either 90deg or 0deg, and clears any existing formula:

    Slider_eg4

    When it is 90deg, the actual folding is actually Factor times this, so can be smoothly increased from 0 to 90 by controlling "Factor".


    We then added a second action XdegAct into the action formula for the slider control, which now looks like this (the semicolon is a separator between the two actions)...

    _systemaction("UpdateFolding");XdegAct
    Now when the slider is moved, the system action still forces a recalculation of just the folding transforms, but the second action XdegAct forcibly updates the value of the variable Xdeg. The updated Xdeg is then used in the next paint of the folded item.

    There is a second control (the edit box) that the user can type into alternatively to directly set the folding %. This also changes the variable Xfoldsliderval, which repositions the slider but does not fire the slider action. So we also need to add XdegAct to the action formula for the edit box.

    Of course, changing the edit box does update the whole item, not just the folding, but since Xdeg does not have a formula in this setup, Xdeg still needs to be explicitly updated.