Another workaround, which allows to still have slider-like input, but is currently a bit inconvenient (ideas (with code) to improve are welcome!), is making a custom control. I've taken this answer as a starting example and reworked it to make it function when LocatorPane
and the like don't work.
It appears that MousePosition
and EventHandler
still appear to work even when this bug is active. So, here's the code for the custom control:
customSlider[Dynamic[i_], str_, b_, e_] :=
Dynamic[
With[{diskSize = Abs[e - b]/60},
EventHandler[
Graphics[{Red, Disk[{i, 0}, diskSize]},
PlotRange -> {{b, e}, {-diskSize, diskSize}},
Axes -> {True, False}, ImageSize -> 300, Background -> None,
ImagePadding -> 10, PlotLabel -> Row[{str, i}]],
{"MouseMoved" :> (If[Abs[Last@#] < diskSize, i = First@#]&@MousePosition["Graphics"])}
]
]
]
And here's how to use it with the example in the OP:
Manipulate[Plot[a x, {x, -3, 3}, PlotRange -> {-1, 1}],
{{a, 0}, (customSlider[#1, "a=", -1, 1] &)}]
It looks like this:
To use it, just move the cursor in the scale, and the red disk will follow it. I tried using "MouseDragged"
as the event, but it works strangely and isn't really usable. Another possible alternative is to use "MouseClicked"
. Even better might be to somehow make a local active
variable and set it to True
on MouseDown
, False
on MouseRelease
and work according to this, but I failed to make Dynamic
work with Block/Module
...
EDIT
It appears that "MouseDragged"
doesn't work as expected because while the mouse button is pressed, no events are generated at all. Thus the only way I see to have some sort of "click to start drag" process is using keyboard keys instead of mouse buttons, i.e. checking state of keyboard keys such as Ctrl via CurrentValue["ControlKey"]
and only setting i
if it returns True
.
Dynamic
things likeSlider
andLocator
. $\endgroup$