Multiple 'Change State' triggers on 1 item
May 26, 2015
I was helping someone else in another thread who wanted to detect CTRL + Click to simulate selecting multiple items in a list (like selecting multiple files from a list in windows).
I came up with a solution by setting a variable with an initial value of False. Then using JavaScript to detect when the CTRL key was down and change the variable to True, and when released change it back to False.
This worked and changes the state of the button only when CTRL + Click are used. The trigger on the menu item was:
Change the state of Rectangle 1 to 'ctrl-pressed' when user clicks if 'keypress' is equal to True
But wanting to take this a little further I want to be able to CTRL + Click the same item and return it back to normal.
To do this I thought I could set 2 triggers on the 1 item. The first trigger is:
Change the state of Rectangle 1 to 'ctrl-pressed' when user clicks - if 'keypress' is equal to True AND Rectangle 1's STATE is equal to 'Normal'
This trigger works fine when it is the only trigger on the item. But if I add the second trigger:
Change the state of Rectangle 1 to 'Normal' when user clicks - if 'keypress' is equal to True AND Rectangle 1's STATE is equal to 'ctrl-pressed'.
When I add this trigger than nothing works.
You can have a look here.
Menu item 1 has both triggers applied.
Menu items 2, 3, 4 only have 1 trigger applied.
9 Replies
Thanks Gary for sharing that solution here - always good to see other ideas and examples.
Thanks, but still need a little help to make it complete.
Anyone got some suggestions for me?
Hi Gary,
Since it involves some more customization based on the Javascript triggers, I'll have to defer to community on assistance with this.
Please keep us posted on any further progress you make, as it's always good to have examples in the forums for other users who run across it.
Ashley,
I don't think it is the javascript that is causing the problem though as the triggers that are causing the issue don't rely on the JS code. They are just checking the status of a variable and state of an object.
The issue is having two change state triggers on 1 object which I think is confusing storyline.
Although I thought it would work because if the conditions in 1 trigger isn't met than it would move to the next trigger, but apparently it doesn't.
Here is a simpler version of what I am talking about.
Hi Gary,
I've come up with a couple of work arounds for your issue. One is instead of using a custom "clicked" state use the built in visited state. The other is to use to hide the shape when clicked and show another shape when clicked. See the example.
Because I want to change it based on the value of a variable, the 'Visited' state won't work I don't think.
I thought of the second option of hiding an object and then showing the other, and I think maybe the only way to do this.
Was hoping to do it without adding more objects on the timeline but I don't think that is possible.
OK,
Updated the file.
You can view it here.
And download the source here.
Thanks David for sharing here - always love to see new examples of how things like this are handled.
This discussion is closed. You can start a new discussion or contact Articulate Support.