# How to make an Epilog moveable with drag and drop

I would like to make an Epilog moveable. For example, the following code generates a Manipulate with a framed pane containing some notes. I would like the user to be able to move those notes anywhere inside the graphics area using a drag and drop. This will allow the user to see what's behind it without completing hiding the notes using the checkbox provided.

Manipulate[
Plot[Sin[a*x] - .3, {x, -3, 3},
Epilog ->
Inset[If[t,
Framed[Pane[
"I want the user to have the abilty to move this box anywhere
inside this white area so the user can see what's behind it.", 70],
Background -> LightBlue, RoundingRadius -> 4,
BaseStyle -> Gray], ""], {Right, Bottom}, {Right, Bottom}]], {a,
1, 10}, {{t, True, "Hide/Show Notes"}, {True, False}}]


How would I go about programming this? I was thinking about using a locator control but not sure if this is the best way. I want to be able to click ANYWHERE on the framed pane and drag it anywhere in the graphics area. It seems like there should be a simple way to do this. Ideas?

• I would like the user to be able to move those notes anywhere inside the graphics area using a drag and drop From usability point of view, I do not think this is a good idea for GUI. I do not want to look at something where I have to move stuff using the mouse on it to see what behind them or around them. User will also have to know they can use the mouse to do this. This is all too hectic if you ask me. Having a button to show/hide notes is a fine idea. But not having user move the notes around with the mouse. – Nasser Dec 25 '17 at 8:05
• one way: add the control {{loc, {1, 1}}, {-3, -2}, {3, 1}, ControlType -> Locator, Appearance -> None} to Manipulate and replace the first {Right, Bottom} inside Inset with loc. – kglr Dec 25 '17 at 8:08
• Hmmm... you may be right. But on the flip side the user does not "have to" move stuff to see what's behind it. I have a checkbox for that. Also, it is intuitive to try and move a things that are in the way with the mouse, so I don't see that being an issue. I look at this as something most of time people won't need, but there are some times when I really want to move a note box a little bit to get a slightly better view, but I can't. I'll post solution and see what people think as far as usability. – Michael McCain Dec 25 '17 at 8:11
• As I said, having a check box to show/hide notations, is good idea. It is the user needing to reach to the mouse and move stuff around which I do not think is needed. But it is your GUI and you are free to do it as you want., I was just giving my 2 cents worth opinion ;) – Nasser Dec 25 '17 at 8:30
• Something like this mathematica.stackexchange.com/questions/14556/…? – Mike Honeychurch Dec 25 '17 at 8:52

Related: 14556 and 7547

Using Locator to give you the control you are seeking :

Manipulate[
Plot[Sin[a*x] - .3, {x, -3, 3}, Epilog -> {Dynamic[If[t,
Locator[Dynamic[pt],
Framed[Pane[
"I want the user to have the abilty to move this box \
anywhere
inside this white area so the user can see what's behind \
it.", 70], Background -> LightBlue, RoundingRadius -> 4,
BaseStyle -> Gray],
Background -> White, ImageSize -> 150], {}]]}],

{a, 1, 10},
{{t, True, "Hide/Show Notes"}, {True, False}},
{pt, Scaled[{0.5, 0.5}], None}
]


• Yes! This works great! I tried extending this to a three dimensional plot but running into issues. Is this possible using the same technique? Ooops... yes locators don't work in 3d right? Any tips on how to get similar functionality for 3 dimensional graphics. – Michael McCain Dec 25 '17 at 9:36
• @MichaelMcCain if you wanted to use a Locator maybe you could try with one dimension constant so that the locator moves within a plane in the 3D. But depends on your use case how good that would look. – Mike Honeychurch Dec 25 '17 at 10:35
• I see. I'll play around with that idea. It does seem to be not nearly as straightforward, Thank you! – Michael McCain Dec 25 '17 at 10:47
Manipulate[Plot[Sin[a x] - .3, {x, -3, 3}, Epilog ->  Dynamic@Inset[If[t, Framed[
Pane["I want the user to have the abilty to move this box \
anywhere
inside this white area so the user can see what's behind it.",
70], Background -> LightBlue, RoundingRadius -> 4,
BaseStyle -> Gray], ""], loc, Center]],
{a, 1, 10},
{{t, True, "Hide/Show Notes"}, {True, False}},
{{loc, {1, 1}}, {-3, -2}, {3, 1}, ControlType -> Locator, Appearance -> None}]


• This works great however, I would I would only like to it move the notebox if you click and drag on the notebox. It currently moves if you click anywhere. Ideas? Sorry I had to uncheck answer because it didn't quite solve the problem as described. – Michael McCain Dec 25 '17 at 8:20
• @MichaelMcCain, can't think of a way to do that with locators off the top of my head . I will update if i find a fix. – kglr Dec 25 '17 at 8:22
• Ok... Thanks Kglr! I will keep at it as well! – Michael McCain Dec 25 '17 at 8:23