Message Boards Message Boards

0
|
220 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

A button for subscipted variables

Posted 19 days ago

I want to have a palette that includes a button for defining subscripted variables as symbols. As this is only needed once per session, I also want the button to change colour when pressed. The code I am trying is attached. However, whilst it changes colour when pressed it does not change subscripted variables to symbols. Yet, if I use the Symbolize function on its own i.e. not in a button, it works. Is this a bug or am I doing something wrong?

subscripts = DynamicModule[{c},
  subscripts = Dynamic@Button["\!\(\*SubscriptBox[\(x\), \(y\)]\)",
     c = RGBColor[1, .1, .1];
       Needs["Notation`"];
       ?Notation`Symbolize[NotationTemplateTag[Subscript[_, _]] ];
     RunScheduledTask[
      RemoveScheduledTask[$ScheduledTask], {0}, AbsoluteTime[] + 3], 
     Appearance -> {"DialogBox", "Palette"}, FrameMargins -> 0, 
     Background -> c, ImageSize -> 92, Method -> "Queued"], 
  Initialization :> {c = White}]
POSTED BY: malcolm woodruff
2 Replies

See if this works to turn your subscripted variables to symbols.

I had a similar question answered by Hans Milton at Need help using Notation Package.

POSTED BY: Jay Gourley

I was aware of the need to be careful with Symbolize. The problem was getting it to work in a buttonm which then forms part of a palette that sets up my Notebook the way I want it to do engineering calculations. With a little help from tech support and Notebook assistant, I have settled on the following code.

subscriptButton = DynamicModule[{isPressed = False},
    Button[
       Style[Subscript[X, y], FontSize -> 16],
       (
         isPressed = ! isPressed;
          Symbolize[ParsedBoxWrapper[SubscriptBox["_", "_"]]]
        ),
       Appearance -> {"DialogBox", "Palette"},
       FrameMargins -> 0,
       Background -> 
    Dynamic[If[isPressed, RGBColor[1, 0.9, 0.8], White]],
       ImageSize -> 92,
       Method -> "Queued"
   ],
    Initialization ->  Needs["Notation`"]
  ]
POSTED BY: malcolm woodruff
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract