2
$\begingroup$

I've tried the following code to change the FieldSize but I can't make it equal the actual value of MenuSize and I tried to remove first Delimiter but I can't.

ActionMenu["PopupMenu", 
 Flatten@Table[{Delimiter, lable1}, {ittration3, 1, 3}], 
 Appearance -> "PopupMenu", Enabled -> True, 
 Background -> RGBColor[0.235, 0.486, 0.768], FieldSize -> 6]

And please tell me how to change the background color of the field.

$\endgroup$
1
  • $\begingroup$ Use Riffle[{"Label1", "Label2", "Label3"}, Delimiter] to introduce delimiters only between labels. $\endgroup$ Dec 21, 2012 at 16:35

3 Answers 3

1
$\begingroup$

On Mathematica 9 (OSX), Background doesn't colour the default PopupMenu button, it just colours the background around the button. Here's a manual version:

act = Rest[
   Flatten@Table[{Delimiter, "label " <> ToString[i]}, {i, 1, 3}]];

am = ActionMenu["PopupMenu", act, Appearance -> None, 
   Background -> RGBColor[0.235, 0.486, 0.768], 
   ImageSize -> {150, 32}, FieldSize -> 10.83];

popup = Graphics[{LightBlue, Rectangle[{0, 0}, {170, 32}],
    Inset[am, {75, 16}, Center, {150, 32}],
    Inset[Style["\[FilledUpTriangle]", Black, 9], {160, 21}, Center],
    Inset[Style["\[FilledDownTriangle]", Black, 9], {160, 11}, Center],
    Black, Line[{{0, 1}, {169, 1}, {169, 32}, {0, 32}, {0, 1}}]},
   PlotRange -> {{0, 170}, {0, 32}}, ImageSize -> 170];

popup

enter image description here

$\endgroup$
2
  • $\begingroup$ I tried your idea but i want that dropdown list size should be same as PopupMenu's size and i want dropdown marker next to string("PopupMenu") . $\endgroup$
    – niren
    Dec 21, 2012 at 11:02
  • $\begingroup$ @niren - I have edited my answer, matching the sizes using FieldSize for the popup fields, and ImageSize for the button. I also included a dropdown marker. $\endgroup$ Dec 21, 2012 at 19:31
2
$\begingroup$

You can do this with PopupMenu. Try this code.

popupMenuValue = "PopupMenu";
{PopupMenu[Dynamic[popupMenuValue], 
    {"Label1", "Label2", "Label3"}, 
    "",
    Row[{Panel[Style["PopupMenu", White], 
                  Background -> RGBColor[0.235, 0.486, 0.768],
                  Alignment -> Center,
                  ImageSize -> {180, 60}], 
         Panel[Style["∨", White], 
                  Background -> RGBColor[0.235, 0.486, 0.768], 
                  ImageSize -> {30, 60},
                  Alignment -> Center]}], 
    MenuStyle -> {25, Blue}, Alignment -> Center, Appearance -> None], 
Dynamic[popupMenuValue]}
$\endgroup$
2
  • $\begingroup$ I don't understand what you intend to accomplish by wrapping your PopupMenu expression in a list with Dynamic[popupMenuValue]. $\endgroup$
    – m_goldberg
    Dec 21, 2012 at 18:31
  • $\begingroup$ what I am trying ,dynamically we can do all computation's by using PopupMenu instead of ActionMenu $\endgroup$
    – subbu
    Dec 22, 2012 at 9:07
1
$\begingroup$

Is this what you mean you want? Use Full to obtain the Full size

act = Table[{Delimiter, lable1}, {ittration3, 1, 3}];

ActionMenu["PopupMenu",
 Flatten@act,
 Appearance -> "PopupMenu",
 Enabled -> True,
 Background -> RGBColor[0.235, 0.486, 0.768],
 FieldSize -> Full]

enter image description here

$\endgroup$

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.