2
$\begingroup$

I'm trying use LocatorPane to produce locators that can move anywhere in the entire row of text I am displaying and not just in one of the rectangles, which is what happens in the code below.

DynamicModule[{pt1 = {0.1, 0.95}, pt2 = {0.5, 0.95}}, 
  LocatorPane[Dynamic[{pt1, pt2}],
    Row[{
      "Brian O\[CloseCurlyQuote]Nolan\[CloseCurlyQuote]s The Third Policeman ", 
      Graphics[{EdgeForm[Thin], White, Rectangle[{3, 1}, {0, 0}]}], 
      " begins and ends with the character of Sergeant Pluck ", 
      Graphics[{EdgeForm[Thin], White, Rectangle[{3, 1}, {0, 0}]}], 
      " asks: \[OpenCurlyDoubleQuote]Is it about a bicycle?\[CloseCurlyDoubleQuote] \
was only published after \
O\[CloseCurlyQuote]Nolan\[CloseCurlyQuote]s death."
    }]
  ]
]

enter image description here

Using GraphicsRow allows the pane to move across the text, but this distorts the view of the text.

Does anyone have a better way of doing it? It has to be able to be cloud deployed.

$\endgroup$

1 Answer 1

1
$\begingroup$

Perhaps something along the lines of the following will work for you.

DynamicModule[{pt1 = {8, .5}, pt2 = {21, .5}},
  LocatorPane[Dynamic[{pt1, pt2}],
    Graphics[
      {{FaceForm[], Rectangle[{0, 0}, {35, 1}]},
       Inset[
         Row[
           {"Brian O\[CloseCurlyQuote]Nolan\[CloseCurlyQuote]s The Third Policeman ",
            Graphics[{EdgeForm[Thin], White, Rectangle[{3, 1}, {0, 0}]}],
            " begins and ends with the character of Sergeant Pluck ",
            Graphics[{EdgeForm[Thin], White, Rectangle[{3, 1}, {0, 0}]}],
           " asking: \[OpenCurlyDoubleQuote]Is it about a bicycle?\
\[CloseCurlyDoubleQuote] was only published after \
O\[CloseCurlyQuote]Nolan\[CloseCurlyQuote]s death."}]]},
      BaseStyle -> FontSize -> 13,
      ImageSize -> 1200]]]

graphics

$\endgroup$
3
  • $\begingroup$ Thanks for the edit and answer, I edited the question to highlight that I need it to deploy it on the cloud and with what you answered with it doesn't work. $\endgroup$
    – Tim B
    Jul 14, 2020 at 9:20
  • $\begingroup$ @TimB. I don't use the Wolfram Cloud, so I know nothing about cloud deployment. Sorry, but I can't be of further help. $\endgroup$
    – m_goldberg
    Jul 15, 2020 at 1:23
  • $\begingroup$ @TimB can you make this part of your question more apparent? Using something like a header formatting with markdown would make it stand out more. You might have better luck if you alter the wording of the actual question to include this. $\endgroup$ Jul 19, 2020 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.