3
$\begingroup$

I created a style in a private stylesheet called "GreenStyle". Here it is

Cell[StyleData["GreenStyle"],
 FontColor -> RGBColor[0, 0.67, 0]]

In the notebook, I then created a button using this style.

Button[Style["My Button", "GreenStyle"],
 , ImageSize -> 120]

enter image description here

When I create a palette using this button, the color will not display as green for some reason.

CreatePalette[Button[Style["My Button", "GreenStyle"],
   , ImageSize -> 120]];

enter image description here

Can you explain why I'm getting this behavior? And what can I do to fix this?

$\endgroup$
0

1 Answer 1

4
$\begingroup$

Palette is a notebook so if you want to use that style there you have to set a stylesheet for it which will contain that style.

The solution is closely related to Inheriting Stylesheets when using CreateDocument but not as straightforward since your private stylesheet inherits from Default.nb while a palette should from Palette.nb.

Let's replace it then:

CreatePalette[
   Button[Style["My Button", "GreenStyle"], ImageSize -> 120],
   StyleDefinitions -> CurrentValue[
     EvaluationNotebook[], StyleDefinitions
   ] /. Cell[
      StyleData[StyleDefinitions -> "Default.nb"]] :> Cell[ 
      StyleData[StyleDefinitions -> "Palette.nb"]
   ]
];
$\endgroup$
2
  • $\begingroup$ This works great! TY. I've run across Core.nb and Default.nb in editing stylesheets for a notebook, however, I've never run across Palette.nb. Is this the "default" stylesheet for paletes? Where do I find it? I'm thinking it may be fun to edit it in a private stylesheet. $\endgroup$
    – B flat
    Nov 19, 2016 at 20:05
  • 1
    $\begingroup$ @MichaelMcCain Yes it is. It can be found next to all other stylesheets. Here is some more info: 82712 $\endgroup$
    – Kuba
    Nov 20, 2016 at 14:16

Your Answer

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

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