1
$\begingroup$

I would like to get an output text when I select every option of popup menu, the input below print me the option but outside the cell displaying panel generated with Manipulate. I have been trying other options without results, there is a way to print inside the cell displaying panel like an output text while you change the option of the popup menu?

Manipulate[
  ActionMenu["Text", 
    {"a" :> Print["a"], b :> Print["b"], c :> Print["c"],d :> Print["d"]}]]

With another example I tried to use Dynamic Panel with the same result.

Manipulate[
  Dynamic @ 
    Panel[
      ActionMenu["Text", 
        {"a" :> Print["a"], b :> Print["b"], c :> Print["c"], d :> Print["d"]}]]]

enter image description here

I need something like (I used "Paint" to do this idea):

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

I think you trying too hard. I believe all you need is the action menu. I can think of two version you might consider. The 1st produces print cells because it uses Print; the 2nd produces text cells like those created by selecting Style > Text in the Format menu.

ActionMenu["Text", # :> Print[#] & /@ {"a", "b", "c", "d"}]

print_cell

ActionMenu["Text", # :> CellPrint[TextCell[#, "Text"]] & /@ {"a", "b", "c", "d"}]

tex_cell

Which one you should choose will depend on what kind of look and feel you want from the created cells.

Update

On basis of additional information supplied by the OP, I have concluded the OP is looking for a fancy version of a Manipulate panel that will put text selected from the popup menu into a field from which it can cut and pasted into other windows on his screen. If I'm right, then perhaps something like this will work for him.

Framed[
  Manipulate[
    InputField[Style[txt, "SR", 14, "Output"], FieldSize -> Small],
    Pane[Style["Chose a word", "SB", 12], ImageMargins -> {{45, 45}, {0, 5}}],
    {{values, StringSplit["the quick brown fox jumped over the lazy dog"]}, None},
    {{txt, Dynamic @ values[[1]], Style["     Text", Bold, 11]}, values, PopupMenu},
    AppearanceElements -> None,
    Paneled -> False,
    TrackedSymbols :> {txt}],
  RoundingRadius -> 10,
  Background -> GrayLevel[.9]]

This interactive panel initially looks like this:

initial

After making a choice, it might look like this:

after

$\endgroup$
6
  • $\begingroup$ Thanks a lot for your help, really I am trying to make an "APP" with a window created with Manipulated and I need to print this selection of popup in a textbox inside this window. It is the reason because I must use Manipulate, do you have any idea to do this? I have been trying today also with Style and Grid inside Manipulate without good results, it continues printing outside the Manipulate window. $\endgroup$ Commented Apr 26, 2019 at 7:33
  • $\begingroup$ @EdwinHerrera. I don't understand what you are saying in your comment. A Manipulate expression doesn't create a window. It creates a cell displaying panel with a content pane and controls. It can not be made into a stand-alone app that exists outside of a notebook. Could you edit your question to make your goal more clear? $\endgroup$
    – m_goldberg
    Commented Apr 26, 2019 at 15:07
  • $\begingroup$ I got it, sorry for the mistake, I didn't know the correct word. And also it's not an App, it is a cell displaying panel inside a notebook indeed. Thank you. $\endgroup$ Commented Apr 26, 2019 at 16:52
  • $\begingroup$ @EdwinHerrera. I have updated my answer. Perhaps it is more acceptable now. $\endgroup$
    – m_goldberg
    Commented Apr 26, 2019 at 19:36
  • 1
    $\begingroup$ @EdwinHerrera. I'm glad you find my updated answer useful. Please consider accepting it. You can do that by clicking on the check mark that appears on the left of the answer below the down arrow. $\endgroup$
    – m_goldberg
    Commented Apr 26, 2019 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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