Copy link to clipboard
Copied
Hi, When changing the button "down" state to show that it has been pressed, it does not remain in that state more than one second tops, almost like the rollover state. What's the point of having a down state if the button does not remain in the state? I end up creating an advanced action changing the button to a custom state, which is not very practical. What am I missing here?
And this is where JavaScript is so useful. You only need to write one function and do everything you want. Including incrementing variables based on which item was clicked. You can even show a greyed out button if what you want to do is show the user what they clicked on already.
Copy link to clipboard
Copied
Do you mean that when holding the mouse down on the button, the state changes? It should stay down as long as the mouse is down and you are over the button.
Copy link to clipboard
Copied
That does happen, but I'd like it to change permanently, like any other custom state. I guess that's not possible.
Copy link to clipboard
Copied
Add a fourth custom state 'Pressed' to the three InBuilt states, you can even use a duplicate of the Down state. Use the Success event of the button to launch a standard action (because you probably have already an action) where you add the command:
Change State of Button to Pressed
What you are asking for is not common practice for buttons. But if you use a shared action, and label the fourth custom state for all buttons the same way, it is pretty easy to add that shared action to each button. Moreover if you are aiming only at HTML, using the CpExtra widget by InfoSemantics with its @ and # syntax will make it even easier.
Copy link to clipboard
Copied
Thanks!
Copy link to clipboard
Copied
I've done that before, but not with state changes. I created a second image of the button toggled down (new colors, fonts, etc.), and made sure it wasn't visible in the normal output. Then I showed the image as part of an Advanced Action call. Pretty easy, really.
Copy link to clipboard
Copied
Yes, that's what I do all the time. But working with a question sheet with ten questions and four options each, it would be easier if the state would just change to down when pressed, and STAY DOWN, and then you could use the advanced actions to increment a variable, for score, let's say. Otherwise you have to create an advanced action for each one of the 40 buttons... Not very practical. Once pressing Enter (or whatever), students will see which button they pressed, and which one was the right answer (using the final advanced action to show right and wrong marks according to the variable incrementation the button triggered). You can use a next button for each question too, which would increment a variable allowing to create one advanced action with ten conditionals. But still, if the down state would just remain down, it would be great. Thanks anyway!!!
Copy link to clipboard
Copied
And this is where JavaScript is so useful. You only need to write one function and do everything you want. Including incrementing variables based on which item was clicked. You can even show a greyed out button if what you want to do is show the user what they clicked on already.
Copy link to clipboard
Copied
OMG, I wish I knew JavaScript, Guess I'll have to delve into that. You make my mouth water just with the possibilities you mentioned. Tips or hints on the best way to learn JavaScript? Thanks in advance.
Copy link to clipboard
Copied
There are a ton of resources. You can get a ton of snippets and basic instruction here:
You'll need to look at JSON also since the course structure for CP HTML5 output is defined in a JSON object.
Copy link to clipboard
Copied
Thanks a million.