How to show the animation control by default - animation

In this simple control object in mathematica like the following,
Control[{x, 0, 1}]
we have to bring the mouse pointer to the right upper corner of the object to get the hint called "Show Animation Controls" and then click it to see the animation controls like play, step forward etc. Is there a way by setting some options to get all the animation controls OPEN by default so that when one opens a notebook containing dynamic object the animation controls remains open?
Anybody knows such a magic option in Mathematica?
As suggested the following code from documentation center
Manipulator[0.3, Appearance -> "Open"]
looks fine and does suits my purpose but how the same can be done with in the following? How can we keep the animation control in Manipulate open by default?
Manipulate[Plot[Sin[a x + b], {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]
This was my actual question that still baffles me unfortunately.

For example, Manipulator[Dynamic[x], {0, 2}, Appearance \[Rule] "Open"].
Can you give more details on what you are trying to do?
EDIT: Does this
Manipulate[
Plot[Sin[a x + b], {x, 0, 6}],
{a, 1, 4, Appearance \[Rule] "Open"}, {b, 0, 10, Appearance \[Rule] "Open"}]
do what you want?

Control is a magical command which guesses the type of controller you want from the arguments you give it. The default one you produced with Control[{x,0,1}] is actually a Manipulator - to have it open from the start you want
Manipulator[x, {0, 1}, Appearance -> "Open"]
Of course x should normally by a Dynamic object.
Another option, if you really want to have a control to simply animate something, is to use
Animator[Dynamic[x], {0, 1}, (*AnimationRunning -> False*)]
where you can uncomment the option if you don't want the animation running when the output is created.
Aside: I had completely misread what acl said in his answer - and it turned out to be the same as what I ended up saing. I should probably just move my comments to a comment in his answer...

Related

Draftsight / AutoCAD - How to show/hide Multiple Layers # the Same Time?

Is there a way to show/hide multiple layers # the same time?
For example, I have layers 1, 2, 3, 4, 5, ...
Assume there is a button if you press. layer 2, 4 & 5 are visible. The others are hidden.
If you wonder why, I have a complex drawing of a machine. The technician might not want to show all the components in that drawing before he prints the drawings. So I want to give him a quick method to accomplish that. One click will show & hide bunch of layers (Edit: instead of selecting one by one. He will not know which layer is which).

How to control font appearance in Manipulator input field?

Apologies for making something that is probably trivial my first question here but I just realized I do not know how to style the font within the input field in a Manipulator control. None of the options for this function are for styling within the input field (AFAIK). I wondered whether an input field option would work:
Style[Manipulator[0.5, Appearance -> {"Open", Tiny}],
DefaultOptions -> {InputField -> {BaseStyle -> Directive[Red, 16]}}]
but it didn't. I'm assuming this is trivial but it has me stumped.
Edit
I have tried using a local Manipulator style
Cell[StyleData["Manipulator"],
ShowStringCharacters->False,
NumberMarks->False,
FontFamily:>CurrentValue["PanelFontFamily"],
FontSize->24,
FontColor->RGBColor[1,0,0],
FontWeight->"Bold"]
This is changing the font colour and weight (I do not want these changed in my application, just testing what works and what doesn't) but still not changing the font size. If this stylesheet solution worked I guess it would suffice for now but ultimately I would like to have a tiny manipulator in a Manipulate:
{{x, 40, "Hello World"}, 20, 100, 5, Appearance -> "Open",
AppearanceElements -> {"InputField", "StepLeftButton", "StepRightButton",
"HideControlsButton"}, ImageSize -> Tiny}
but with a non-tiny font in the input field, and achieve this by direct coding.
The only way I know to change the size of the text in the field is to hit the entire thing with Magnification. Using Simon's guidance above to do this with Style:
Style[
Manipulator[0.5, Appearance -> {"Open", Tiny}],
DynamicBoxOptions -> {BaseStyle -> Magnification -> 2}
]

How to use AutoAction->True with LocatorPane with more than one Locator?

I am trying to have a LocatorPane with more than one Locator using LocatorAutoCreate option.
But I'd also like to set AutoAction->True, so that when the mouse is over a locator, it moves automatically with the mouse. i.e. works like dragging.
I am basically trying to just have the dragging feature of LocatorPane, and do not want the clicking feature of LocatorPane, as it complicate something else I am doing.
i.e. I just want to be able to just drag points across a locator pane. Clicking on the locatorPane should do nothing. One way to do that I found is by setting AutoAction->True. Is there a better way to disable Clicking effect on LocatorPane?
The problem is that, when I have more than one locator, Mathematica kernel crashes right away.
So, I am asking if there is a way to use AutoAction->True with LocatorPane with more LocatorAutoCreator at the same time. Or if there is a way to just allow dragging, and clicking should do nothing.
Here is an example
LocatorPane[{{0,0},{.4,.5}},
Graphics[{Gray,Disk[]}],
AutoAction->True,
LocatorAutoCreate->{1,5}]
Make sure you save your work before running the above, as it will crash Mathematica once the mouse is over the Pane.
Version 8.0.1, Windows 7.
Update:
FYI; I got a reply from WRI tech support on this today. The problem has been reproduced and send to Mathematica development team to investigate.
You may try:
LocatorPane[{{0, 0}, {.4, .5}, {.1, .1}},
Graphics[{Gray, Disk[]}],
AutoAction -> True, LocatorAutoCreate -> {All}]

ContextPath of a cell

How do you change the $ContextPath of a cell without using Prepend:
$ContextPath = Prepend[$ContextPath, "PackageName`"]
I was looking around at the Documentation for $ContextPath and I decided to evaluate the first input cell in there.
Before Evaluation:
After Evaluation:
I'm guessing that the difference here is that when this documentation was being written WebServices was not enabled for the person writing it. We can see that Global is in the context of that cell because this has been explicitly mentioned. Look at the expression by going to Cell > Show Expression.
The option CellContext is set to Global. Now, lets make a new cell and evaluate $Context.
This means that inside that cell I cannot use any of the global objects that I have created in other notebooks. We can maybe add Global by changing the CellContext option of the cell. We do this by showing the expression and editing. When you evaluate you will see that the context has changed to global. Now, just for the heck of it lets try this in the cell in which we just changed the context to global.
Print["Outside Module = ", $ContextPath]
Module[{},
Print["Inside Module = ", $ContextPath];
Manipulate[
Print["Inside Manipulate = ", $ContextPath];
Row[{
Plot[x, {x, -3, 3}, PlotRange -> {{-3, 3}, {-3, 3}}]
}],
{{p1, {-1, 2}}, Locator, Appearance -> "L1"}
]
]
Do you get something like this:
Why does the context change inside Manipulate? Inside other notebooks this doesn't happen. I'm guessing it has to do with the settings of the reference stylesheet but I just can't figure it out. How can we change the settings of the documenation notebook temporarly so that we can use the global context everywhere throughout the notebook?
So, if I understand you correctly, you're running some commands in a documentation center notebook - and you don't understand the behaviour of context?
The documentation center uses a style sheet (Reference.nb) where the Cell[StyleData["Input"]... has the option CellContext->CellGroup. This can also be seen using the Option Inspector on the pages of the documentation center:
This setting is really hand for the documentation center, since it means that all of the examples in there won't interfere with each other or with your Global` definitions.
You can also set the default context for any particular notebook via the Evaluation menu:

How to improve sensietivity of EventHandler to MouseDragged and MouseClicked events

Using EventHandler, I notice that sometimes it thinks I was dragging the mouse, even though I was just clicking it.
Here is a simple example
EventHandler[Graphics[Circle[{0, 0}, 1]],
"MouseClicked" :> Print["mouse clicked"],
"MouseDragged" :> Print["mouse being dragged"]
]
When I start clicking, even though I make sure the mouse is completely fixed and not moving, and I just keep clicking, and looking at the print messages, once in a while I see the dragging message come out.
I understand this can be sensitive to the mouse (but I have a good mouse), may be even the mouse pad, the OS, and any slight movement by hand, might cause this.
I wanted to ask if someone could try this and see if you notice this problem as well, and if someone knows some setting I can do in Mathematica to minimize this. I was looking for an option to EventHandler to set the time or delay as to when it decides the mouse being dragged, but see nothing.
Here is an example output of what I get on my system when I am just clicking after running the above code
mouse being dragged
mouse clicked
mouse clicked
mouse clicked
mouse clicked
mouse clicked
mouse clicked
mouse clicked
mouse clicked
mouse being dragged
mouse clicked
mouse clicked
This is on windows 7, Mathematica 8.0.1
Thanks
The following is not perfect, but seems to work better:
initMousePos = {-1, -1};
dragged = False;
EventHandler[
Dynamic#Graphics[Circle[{0, 0}, 1]],
"MouseDown" :>
(initMousePos = MousePosition["Graphics"]),
"MouseUp" :>
If[EuclideanDistance[MousePosition["Graphics"], initMousePos] < 2 10^-1,
Print["MouseClicked " <> ToString#MousePosition["Graphics"]],
Sequence ## {}],
"MouseDragged" :>
If[EuclideanDistance[MousePosition["Graphics"], initMousePos] > 2 10^-1,
Print["mouse being dragged " <>
ToString#MousePosition["Graphics"]], Sequence ## {}]]

Resources