A trigger is useful to use for animation, but I am not able to find a way to change the state of the trigger in the code (i.e. without having to hit the Pause or Play button myself).
For example, suppose I want to do a simulation where when some event happen, I want to make the currently active trigger go to a PAUSE state, and when another event happen, I want the trigger to go to PLAY state.
The buttons to do that will still be there, but I want to also be able to change these from the code without having to physically do it.
The reason is, I am doing some action, and having the trigger being in PLAY mode while I am doing this other action is making things not working.
So I need to make it go to PAUSE state, and when I am done, I can set it back to PLAY state.
Here is a small example of what I mean:
Manipulate[
EventHandler[
Dynamic@Graphics[
{Circle[{0,0},1], Text[n,pt] },
PlotRange->All,ImageSize->200,ImagePadding->10],
{
"MouseDown":>
(
(* What to do here to cause the trigger to become Paused?"*)
pt=MousePosition["Graphics"]
),
"MouseDragged":>
(
(* while dragging, the trigger remains in PAUSED state "*)
Print["mouse dragged"];
pt=MousePosition["Graphics"]
),
"MouseUp":>
(
Print["MouseUp"]
(* What to do here to cause the trigger to Play again?"*)
)
}
],
Control[{{n,0,"Run"},0,100,0.01,
ControlType->Trigger, DisplayAllSteps->True, AnimationRate->1,
AppearanceElements->{"PlayPauseButton","ResetButton"}}
],
{{pt,{0,0}},ControlType->None}
]
In above, when I drag the mouse on the display, I want the trigger to become PAUSED so that the number shown is not changing while being dragged. When done with dragging, I can then make the trigger PLAY again if needed.
So, my question: Is there a way to change trigger state like the above in the code?
I can ofcourse not use trigger at all, and code everything myself in other ways, but thought to ask before I give up, as trigger is convenient to use.
Here is a link to more documentation of trigger and the buttons.
The closest thing I found is the Enabled-> option to trigger, but this just makes the trigger itself enabled to not, and does not affect the trigger state. i.e. if trigger is firing, it will remain firing even if I make disabled.
http://reference.wolfram.com/mathematica/ref/Manipulator.html
http://reference.wolfram.com/mathematica/ref/Trigger.html
thanks