The LAYOUTs toggle each time the button is pressed but the button always reads "Desktop" and doesn't change when the if clause is triggered, as I thought it would.
I've been struggling a bit with the @label modifier as well but in a different way. Currently on the 13.6.10 beta.
I've been playing around with a button that has this code below which just toggles between sorting by modified and date. (I know there's probably a more straightforward way to do it with standard functions but I was experimenting with evaluator). Anyway the button works in terms of going between the sorting methods, but the label doesn't change at all from the original label.
My intention is to use eventually $labelText, but that wasn't working, but it doesn't work when I explicitly set it either like is shown below.
What's confusing me is that the above code DOES work if I put it at the top, before the evaluator block. But obviously I want to do it after all the variables are set so I can use them.
Hm I don't really follow. I'm just having trouble understanding how the evaluator block's existence affects the label being set, even if it's not being used in setting the label.
For example take this example button code where I just hard code a label value:
@Output Random Evaluator Example Return: {=
$test="Blah";
return "Hello";
=}
@label "Whatever String"
@Output Variable Value: {$test}
This generates an output of this below (just to illustrate that the evaluator block is running), but the label doesn't change for some reason.
Random Evaluator Example Return: Hello
Variable Value: Blah
However, if I just move the label command to the top like this, it does change the button label to 'Whatever String'. (And the output is the same)
@label "Whatever String"
@Output Random Evaluator Example Return: {=
$test="Blah";
return "Hello";
=}
@Output Variable Value: {$test}
Edit: Ok I just realized it DOES work and change the label if the evaluator block is all on one line like this:
@Output Random Evaluator Example Return: {=$test="Blah";return "Hello";=}
@label "Whatever String"
@Output Variable Value: {$test}
So not sure if I did something wrong with the syntax or just a bug. Or maybe I'm just using the multi-line evaluator feature in an unintended way.
The issue is that Opus buttons aren't necessarily just a sequential list of commands that are processed one after the other. Some @ directives, like @label, are completely ignored when the button is actually run. Instead they're processed separately at other times as part of the dynamic update system.
When that happens, other lines (those that actually form part of the command that is run when you click the button) get skipped.
This is why we have @evalalways - it lets you provide evaluator code that's processed in both cases (during dynamic update and when the button is run).
I got it to work by using @evalalways and only using evaluator variables instead of the $ type variables. So at least now I believe all the variables get updated at the same time, whenever that might be.
I did have to do some funky arrangements of the labelText assignments in terms of which if block to put them in, because the label was basically changing to the opposite of what I expected - I guess because of the order of how stuff is happening behind the scenes.
It took me a bit of time to realize that when doing something like @label=Whatever, the equals sign isn't part of the @ modifier but rather to signify what's next is for the evaluator, so it's basically the same as @label:=Whatever