Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating a button that is only active while being clicked

Enthusiast ,
Dec 05, 2016 Dec 05, 2016

Here's the question: I have to simulate an action that resizes a given shape when I press a button (on the actual device) and hold it down. This means I need a button that will activate when pressed and deactivate when not pressed - is this possible?

As far as the shape, I am assuming I can use multi-state tool for an image to resize to move an image while the button is depressed - the question is, will it spool through the states while it's depressed or do I have to create some sort of animation to run while it's depressed?

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Dec 07, 2016 Dec 07, 2016

Thought about it and solved the problem by digging in the CPM.js file and finding the jscript that controls the go to next state and go to previous state actions.

(NOTE:  I did give up on using an "on click" entry as found in InDesign or Animate since it seemed like it might be incompatible with Captivate)

Let's use an object with 5 states as an example.

To bring the object up on entry in a state that allows both buttons to work on entry create the following advanced action:

Change State of <object

...
Translate
LEGEND ,
Dec 05, 2016 Dec 05, 2016

You could use a scale effect, which can be triggered by a button, and you can control its duration. I don't see how you would try to do this with multi-states, unless you create a sequence of the commands 'Change State' followed by 'Delay Next action'. Seems bit cumbersome.

However Captivate's actions are event driven: it is the Success action, which means clicking on the button, that triggers the action. Captivate has no even for releasing the button. Maybe that can be done with JS, using the cpAPIEventEmitter. Another possibility, which I didn't check out for a use case like yours, is using the CpExtra widget by InfoSemantics which allows you to have multiple events on an object.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 05, 2016 Dec 05, 2016

I want a conditional action that does the following:

set a variable that will indicate what state of an object to show (circle = 0 through 7)

IF: <variable> is equal to 0

THEN:

change state of <object name> to <next state up>

Increment <variable> by 1

Pause

this repeats on six more tabs with each IF statement increasing the variable value by 1 and the THEN statement opening a new state.. The problem is, the action does not pause as directed -it shoot straights through from 0 to seven without stopping.

Question:

can I get this to operate, or am I going to have to create a massive show/hide shared action?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 05, 2016 Dec 05, 2016

Using pause will not help, since you are incrementing and an action is always evaluated totally. Each increment will lead to the next decision being correct.

As I mentioned, combining Delay command with change to a next state could do that trick:

   Change to state one

   Delay next action by 1 second

   Change to sate two

   Delay next action by 1 second

   Change to state three

....

But that is still not solving your first requirement: when the button is released, the action should stop.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 05, 2016 Dec 05, 2016

Unfortunately , the delay next action command is not working as

advertised. The action chain goes immediately through, even with a delay

setting of plus several seconds

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 05, 2016 Dec 05, 2016

How did you test? I used the Delay command several times without problems. Not functional means something else is wrong.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 05, 2016 Dec 05, 2016

I built the delay into each tab of the action on a single slide project.

followed the same structure just adding the delay to the "else" statements,

it did not delay or stop the chained actions from executing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 05, 2016 Dec 05, 2016

Sorry, that is not the way to do it at all. You don't need multiple decisions, not even a conditional action at all, just a standard advanced action as I wrote out before.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 05, 2016 Dec 05, 2016

My mistake, how does the standard action work? didn't see it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 05, 2016 Dec 05, 2016

Create a standard action that looks like this:

  Change to state ...

  Delay Next actions by....

  Change to state....

  Delay Next actions by....

  Change to state....

This will lead to pauzing in between two changes to the state. If you put each change in a decision, with a condition that results in true, all will be done at once. Why do you want to use a conditional action?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 06, 2016 Dec 06, 2016

OK, I now realize what I forgot to mention and it makes all the difference in this discussion. I thought I needed the variable because I wanted to be able to switch between two buttons - one going up and one going down (resizing the object) at whatever state the image was showing at the time. The variable was designed to insure the correct state was showing at a given moment.

The reason I needed to do this was to ensure the states did not cycle from biggest to smallest (using next state, the cycle would be 1-2-3-1) because that would be confusing. The problem is, when building a conditional action, there is no "go to next state" or "go to previous state" command available that would solve the problem. If all it was doing was going to the next or previous state and increment or decrement the variable, this would work the way I wanted.

After sleeping in it - I came up with an even simpler fix. The buttons use the built in go to next/previous state advanced action, and the largest and smallest states include an object that sits on top of the appropriate button, disabling it.

So, it would be optimum if we had the go to next and go to previous state commands available for use in a conditional action drop down menu in order to trigger variables based on repeated choices of a button that could affect future branches or reveals in the project (and be useful in a holistic scoring rubric), but for purposes of my current needs, this will do.

Sorry for the misstatement, Lieve, your solutions are perfect for a demo mode that cycles through all stages on click. I just didn't make myself clear.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 06, 2016 Dec 06, 2016

The object on top of the button does NOT actually disable the button, it simply hides it. If the user clicks on the "hidden button" it will still cycle through (1-2-3-1, etc.). Hopefully, the fact that it "disappeared" will be enough to discourage continued clicks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 06, 2016 Dec 06, 2016

I know that Goto Next State/Previous state is missing from the command list in all advanced/shared actions which can be annoying, but also understandable because it will avoid loops. As for covering an interactive object  by a non-interactive object, the result is different depending on the output: for SWF output the interactive object remains interactive, for HTML output not. Just wanted to offer that extra info. To be safe, you always have to disable an interactive object when hiding it (even when hiding with an action), and enable it after making it visible again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 06, 2016 Dec 06, 2016

Exactly - and I can't disable it or hide it at the limits of the state (defalut state and last state created) without creating a conditional action based on the increments of a variable.

What I would like to build is this:

let's say I have 5 states for an oblect (default, a ,b, c, and d) and I want to be able to go up or down on entry

For the slide the entry action would be

Change state of <object> to b

Assign <variable> with 2

because b would give me two states for the go to next button to access and two states for go to previous button to access.

The buttons would be set up as follows:

Previous State button:

IF

<variable> is not equal to 0

THEN

go to previous state

decrement <variable> by 1

ELSE

Disable go to previous state button

Next State button:

IF

<variable> is not equal to 4

THEN

go to next state

increment <variable> by 1

ELSE

Disable go to next state button

The extended value of this conditional is in the ability to link the value of the increments to tracking the users interactions, and possibly to creating branches based on those clicks. In the simulation I am building, this is used to plot intercepts on a chart. If I gave instructions to plot an intercept at a given point, and the user selected the actions that were counter to the proper methodology, I might want to trigger a second scenario after some further instruction of the use of the controls and plotting intercepts, or I might simply want to score the error as part of the overall interaction. I need a trigger separate from the click to do this, and that's the variable.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 06, 2016 Dec 06, 2016

I still don't know exactly what you want, but it will not be possible with a conditional advanced action like you posted. It is only in very rare situations that you can have THEN/ELSE parts when the action has multiple decisions.  The later decisions will override what happens in the previous ones.  You cannot use 'Go to Next State' at all. Sorry, I'm giving up trying to understand your goal. The action will not stop when you release the button, so you'll only have two possible situations, corresponding with the two states of the toggle butron: either increasing the state number or decreasins the state number. Still don't know why you insiste on using states instead of the Effect to upscale or to downscale.  Neither why you need another variable than a Boolean, which will be set to 0 if the button is in the normal state, and to 1 if it is in the reverse state. Maybe I'm too tired?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 06, 2016 Dec 06, 2016

No problem, Lieve - I'm probably too deep in the weeds on this anyway at this point. No need to respond further, I'll just keep this thread alive in case some else has an idea.

  • Based on what you told me and what I've done I realized the on success  action can only be triggered if the button is clicked and released, so I gave up on holding it down - the object state simply changes by one state each time it is clicked.

  • I know I can't build the conditional the way I described it (the go to next/previous states aren't available) but it was the simplest way for me to show the interaction I want to create, which is:

    • When the user selects a button, there is change up (next state) or down (previous state) of one state from the state currently shown. (Go to Next State and Go to Previous State) - HOWEVER:

    • Allowing the states to cycle through from the last directly back to the first is not acceptable in this simulation - it provides an option not available on the actual software. I need to be able to disable each of the buttons when they reach the first state of the object or the last state of the object respectively.

    • Inserting a variable to increment or decrement on click seems like the only way forward, .The variable builds to a maximum value or reduces to a minimum value. When the variable meets the given value - it triggers the ELSE command (the only time the IF condition is not met is when the variable is equal to the minimum or maximum) and disables the button associated with the next/previous action. I cannot find another way to disable the button.

I think I'm asking the impossible under current conditions in the menus - perhaps its a custom JavaScript answer that would create this advanced action, but it seems beyond the scope of Captivate right now.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2016 Dec 05, 2016

I just tested this out but I thought it might work. Tell me if this works for your project.

  1. Create a button like the one that you need for your interaction.
  2. Click on State View
  3. on the Normal State for your button draw the shape that you need and copy it
  4. Change to the roll over state and paste it there (you may have to reposition it)
  5. on the down state paste it there as well, but increase it's size like how you want it.

Assuming I understand what you are trying to do, I think this should work. I tested it out and it seemed to work like you wanted, however I may have misunderstood what you wanted.

Paul Wilson, CTDP
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 06, 2016 Dec 06, 2016

Paul:

Good idea, but it isn't creating the action I need, because the "go to next state" button needs to be disabled only when the last state of the object is reached and the "go to previous state" button only needs to be disabled only when the default object state is reached. In the simulation we're building, that is the first and last state in a series that may be between 11 and 21 states in total.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 07, 2016 Dec 07, 2016
LATEST

Thought about it and solved the problem by digging in the CPM.js file and finding the jscript that controls the go to next state and go to previous state actions.

(NOTE:  I did give up on using an "on click" entry as found in InDesign or Animate since it seemed like it might be incompatible with Captivate)

Let's use an object with 5 states as an example.

To bring the object up on entry in a state that allows both buttons to work on entry create the following advanced action:

Change State of <object name> to <state name>

(if I wanted to have the object start with an equal number of clicks for previous and next state command, I would select the state name assigned to the second new state I created.)

Assign <variable> with <literal>

(in order to make the conditional sync up with the current view on entry, this number would be 3 - the midpoint of the variable value range)

Here's the conditional action for "Go To Next State" that will disable the "Next State" button when it reaches the last state created:

IF

<variable> is not equal to <literal>

(for example, if the object had 5 states, and you create the variable with a value of 1 - the literal number here would be 5, as each click will increment the value by 1 as shown below)

THEN

Execute JavaScript 'cp.goToNextState("object name");cp.actionChoicePauseMovie();' in current window

Increment V <varaible> by 1

Enable <Go To Previous State Button name>

ELSE

Disable <Go To Next State Button name>

and here's the conditional action for "Go To Previous State" that will disable the "Previous State" button when it reaches the object's default state:

IF

<variable> is not equal to 1

(the variable is created and assigned a value 1 - therefore the default state will occur when the value reaches 1)

THEN

Execute JavaScript 'cp.goToPreviousState("object name");cp.actionChoicePauseMovie();' in current window

Decrement <variable> by 1

Enable <Go To Next State Button name>

ELSE

Disable <Go To Previous State Button name>

the actions above prohibit the states from cycling. The states can go from default through intermediate to last state (1, 2 3, 4, 5), last  through all intermediate to default (5, 4, 3, 2, 1) and back and forth infinitely within this series selecting the buttons associated with the actions, but cannot switch directly from 5 to 1 (4, 5,1) or from 1 to 5 (2, 1, 5) as the standard advanced action allows.

The variable value can also be used to more than simple state changes. It can trigger feedback or open/close branched activities based on the selections made by simply adding i to the IF and ELSE lines as needed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources