Explore the community Forums Lectora Lectora Questions & Answers Trigger on variable change

Tagged: 

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #411342 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    18 pts
    @approg

    How do I trigger an action when a variable’s value changes?

    I thought about making a loop and test very second of so but it seems a clunky way to do it.

    #411376 Score: 0
    Profile photo of Stan Miller
    Stan Miller
    Member
    beginner
    intermediate
    LUC16 Attendee
    wise owl
    contributor
    curious george
    friend finder
    LUC17 Attendee
    30 pts
    @smiller7502

    I don’t think there’s a way to do that — but you should be able to trigger an action from whatever it is that’s changing the variable.

    #411380 Score: 0
    Profile photo of Dana Musser
    Dana Musser
    Member
    beginner
    intermediate
    junior moderator
    contributor
    friend finder
    LUC16 Attendee
    curious george
    wise owl
    6 pts
    @danam

    Hello approg:

    This is very simple. Stan, actually is correct. It is something that must be triggered. You know where it needs to be placed dependent on the need for it.

    If I understand correctly, you want the action to happen as soon as the modification of the variable happens. This will require a check at that very point. Add a second action, after the modification action, to do whatever is required if the variable is satisfied. Be sure to delay this action by at least 2 tenths of a second to allow the computer modification to run.

    Hope this helped!

    #411461 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    18 pts
    @approg

    Thanks for the help but I should’ve provided more background information.

    We’ve had an “interesting” interaction built for us in HTML5 that I’ve dropped into Lectora. The interaction changes the value of an Lectora custom variable when it’s been completed. A few things in the Lectora title are inactive until the interaction has been completed.

    I don’t want the developer of the interaction to hardcode anything other than the name of the Lectora variable (so that I can reuse the interaction in other titles). So I’d like my Lectora title to know when the variable has been changed and to then trigger an action.

    #411467 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    106 pts
    @mnotermans5114

    Ask your developer to change or add the complete action to call an Actiongroup. In that group you then can add whatever you want.

    #411470 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    18 pts
    @approg

    Thanks but while that would work in this instance, it means that the action or action group’s name would need to be hard coded into the interaction – which is something I’d rather not have done.

    #411474 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    251 pts
    @timk

    It may be an idea to use a button instead of an action group. The button could be targeted by classname from the interaction, so it would easier to copy or reproduce without changing the interaction.

    #411724 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    18 pts
    @approg

    I like the idea of using a button, thanks.

    #411731 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    106 pts
    @mnotermans5114

    Following up on Tim’s idea of using a button with a className. You could use a transparant button/element, on completion trigger that transparant button to become visible ( from the Html interaction ) and on that button/element you have onShow actions that will trigger whatever you want. This way on completion things can happen without user interaction. If you design the button/element to fit into the overall design it will look seamless.
    You even can use a incredible small element ( 1 pixel ) to have no visual impact.

    #411734 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    251 pts
    @timk

    Lectora creates an action group for each button called “button123.onUp()”  that runs all On:Click actions. You can just run that function from javascript.

    #411737 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    18 pts
    @approg

    I’ve started looking into in earnest and it seems to be a good approach.

    One issue I’m having is how to trigger the onUp from withing the interaction when the title is published for seamless. Lectora is putting the interaction within one iframe which is within another iframe.

    #411739 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    106 pts
    @mnotermans5114

    Interesting Tim… wondering however if and how that works.. in Lectora Online ( and probably the same approach now in Lectora 18 ) a textbutton on screen is renamed in the HTML to…
    <div id=”tobj3462″  class=”testBttn” >
    <button name=”3462button”>
    The latter…button name is only given several divs deeper, since now Lectora uses SVG for creating the graphics for the button. The className testBttn can be given to it as before…

    When i check the Trivantis generated code in Lectora Online… i find these codes for the buttons on my page…
    var textbutton3025 = new jsWndTextButton(); //ExitClose
    var textbutton2386 = new jsWndTextButton(); //Prev
    var textbutton3462 = new jsWndTextButton(); //Button 5
    var textbutton2388 = new jsWndTextButton(); //Next
    var textbutton2393 = new jsWndTextButton(); //TOC

    Interesting…

    #411931 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    18 pts
    @approg

    Instead of using a button I used a small text box that contains just a single space (so that the text box is never visible). The text box is hidden and then I use JavaScript to make it visible and as it shows it triggers an action(s) attached to it.

    The text box has a CSS class added to it called “foo” (it doesn’t matter that the associated CSS doesn’t exist.)

    The relevant js in the interaction looks like

    var p = parent.window,
    t = p.document.querySelector(“.foo”);

    if (t && t.id && p[t.id + “actionShow”]) {

    p[t.id + “actionShow”]();
    }

    #411964 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    251 pts
    @timk

    The code for using the button is basically the same.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.