@eval and @label behave differently depending on the button type or command

I am trying to create a button that changes the label text and color depending on whether dark mode is on or off.

I have found that this works:

@eval:darkModeOn = SysInfo("DarkMode") ? ("<#1aff00>Copy: Dark Mode is On</#>") : ("<#e60000>Copy: Dark Mode is Off</#>")
@label:=darkModeOn
Copy

Adding an argument to the command makes the button no longer work. It reverts to the original label and color.

@eval:darkModeOn = SysInfo("DarkMode") ? ("<#1aff00>Copy: Dark Mode is On</#>") : ("<#e60000>Copy: Dark Mode is Off</#>")
@label:=darkModeOn
Copy COLLLIST

What is happening here?

1 Like

Copy COLLIST is a dynamic command that generates other buttons. Outside of Customize mode the parent button isn't visible at all, only the buttons it's generated.

Thanks for the response, that makes sense.

Do you have a recommended way to accomplish this for dynamic commands and menus?

Currently my workaround is to make duplicate light/dark mode buttons and place them in two sets of hide blocks. This isn't too bad except that my toolbars overflow when entering customize mode. Just wondering if there is a cleaner method.

//hide if dark mode is on
@hideif:=SysInfo("DarkMode")
@hideblock:begin
//hide if dark mode is off
@hideif:=!SysInfo("DarkMode")
@hideblock:begin

I think the only other way to do it would be to have individual buttons for each collection you wanted to list. (Which would no longer dynamically list new collections, of course.)