# A button for subscipted variables

**URL:** <https://community.wolfram.com/t/a-button-for-subscipted-variables/24851>\
**Category:** Questions\
**Tags:** interface-construction, packages-and-paclets\
**Created:** [December 8, 2024, 7:37am UTC](https://community.wolfram.com/t/a-button-for-subscipted-variables/24851 "2024-12-08T07:37:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mail2](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mail2/32/17287_2.png) [@mail2](https://community.wolfram.com/u/mail2)\
**Post date:** [December 8, 2024, 7:37am UTC](https://community.wolfram.com/t/a-button-for-subscipted-variables/24851/1 "2024-12-08T07:37:43Z")

</div>

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}]

```

---

<div class="post-metadata">

**Author:** ![jgourle2](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/jgourle2/32/4175_2.png) [@jgourle2](https://community.wolfram.com/u/jgourle2)\
**Post date:** [December 17, 2024, 12:08am UTC](https://community.wolfram.com/t/a-button-for-subscipted-variables/24851/2 "2024-12-17T00:08:57Z")

</div>

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

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/0394774e-747f-43e1-9552-587f55277c1f)

I had a similar question answered by Hans Milton at [Need help using Notation Package](https://community.wolfram.com/groups/-/m/t/3338461?p_p_auth=47LTS9rl/) .

---

<div class="post-metadata">

**Author:** ![mail2](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mail2/32/17287_2.png) [@mail2](https://community.wolfram.com/u/mail2)\
**Post date:** [December 17, 2024, 7:52am UTC](https://community.wolfram.com/t/a-button-for-subscipted-variables/24851/3 "2024-12-17T07:52:54Z")

</div>

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`"]
  ]

```
