Forum Discussion

SharonGoza-f625's avatar
SharonGoza-f625
Community Member
7 months ago

Setting position of slider via trigger

Is there any way to set the position of a slider via a trigger.  This doesn't work. The slider moves to each step. I've tried both "When learner releases" and "When slider is dragged"

 

  • AndrewHanley's avatar
    AndrewHanley
    Community Member

    Absolutely! If you change the variable for that Slider, then the slider position automatically moves.

    You can change this value in any way you want (eg. button - "When user clicks Button 1 adjust variable Slider 1 value to x") etc etc

  • If the user moves the slider, the variable automatically adjusts based on the position the slider is moved to.

    Conversely, as Andrew said, if the slider's variable is adjusted with a trigger (for example, adjust the variable when another object is clicked), the slider automatically moves. 

    However, a trigger that tries to adjust the value of the variable when the slider moves is going to cause problems.

    This is in direct conflict with what the program does automatically. 

  • Let me tell you what I'm trying to do. The user can slide one stop at a time forward, and any number backwards. This is to make sure they view the forward content in order but can refer to a previous location if they need to.  Can you do that with a slider.

     

     

  • You can do it. The most significant part is that you need to keep track of where they are.

    Create a variable (I’ll call it MaxNumberAllowed) with a default value of 1.

    Create a trigger: Set variable slider1 to MaxNumberAllowed when Slider1 changes if Slider1 > MaxNumberAllowed. This is the secret sauce that doesn’t allow them to advance. Change slider1 when learner releases. Create a second trigger (which must be lower in the trigger list than the other one.): Go about your business (show layer, jump to slide, eat lunch, whatever) when slider1 changes if slider1 <= MaxNumberAllowed.  This is the secret sauce that keeps it from doing business twice if they move the slider took far. When business is completely finished, change MaxNumberAllowed.

    If you try to change MaxNumberAllowed by adding to it, there is a potential for trouble. Imagine this scenario: they go to step three, you add 1 to MaxNumberAllowed, then they go back to step two. When it finishes you add 1 to MaxNumberAllowed. Now they can go to step 5 without going to step 4. What you need to do at the end of each step is to set MaxNumberAllowed to the appropriate number for the next step. This is the secret sauce that keeps track of where they are and how far they can go. That way, repeated visits to a step won’t mess up the requirement that they can advance only to the immediately following step.

    Any questions ask.

  • This doesn't seem to work. The slider value stops at the max, but the sider itself is in the higher position and doesn't move to a lower position. So, the user will have no idea why they're not seeing the item referenced by the slider.  It's a very simply story file, so here it is.

    Here's the output if you slide past position 2:

    As you can see, with the default of 10 increments, the box on the slide bar is way past 2, but the slider variable is now at 2 which is the current max.

  • It's a question of timing, somewhat esoteric, but in essence the dropping and changing are all occurring too close to each other. When they are stretched out a little, it works, so I added a delay.

    I also changed the slider Update to When learner releases. Using When slider is dragged can result in the system taking the slider away from the learner.