Dynamic icon in CTB context menu caption with alias not working

Things you’d like to miss in the future...
autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Dynamic icon in CTB context menu caption with alias not working

Post by autocart »

Hi Don,
I want to file this as a bug and hope that you agree.
Paste the CTB snippet into a CTB.
The right click context menu should show an icon on the left side of the first entry, but it only shows a "?" icon.

That the aliases are recognized, you can see, e.g., if you delete the pipe character. Besides, the normal text of the caption is dynamic. This part works well. So, the icon should work too, right? But doesn't.
I also tried putting the pipe and colon both into the caption directly or both into the alias. Or the whole string into one alias instead of two. Nothing makes the icon show up.

If I type ":dark" or ":sync" into the first line of "ScriptR" after the pipe directly, then it works: The icon is displayed.

Code: Select all

Snip: CTB 1
  XYplorer 22.30.0204, 23.10.2021 01:00:18
Action
  NewUserButton
Name
  
Icon
  
ScriptL
  
ScriptR
  "<@autocart_label_ToggleLocationCEAs>|<@autocart_label_ToggleLocationCEAs_Icon>"
   if (tweak("SkipBrowseEvents") == 1) {
    tweak("SkipBrowseEvents", 0);
   } else {
    tweak("SkipBrowseEvents", 1);
   }
  "_Initialize"
   if (tweak("SkipBrowseEvents")==1) {
    goto "@autocart_label_ToggleLocationCEAs=[Location CEAs are OFF]: Activate";
    goto "@autocart_label_ToggleLocationCEAs_Icon=:dark";
   } else {
    goto "@autocart_label_ToggleLocationCEAs=[Location CEAs are ON]: Deactivate";
    goto "@autocart_label_ToggleLocationCEAs_Icon=:sync";
   }
FireClick
  0

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Dynamic icon in CTB context menu caption with alias not working

Post by admin »

Sorry, no time to walk through this. Try to narrow it down.

autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Re: Dynamic icon in CTB context menu caption with alias not working

Post by autocart »

I can try to shorten the description of the problem. (The problem itself is super narrow already.)

Problem deals with:
Icon in caption of a CTB context / pop-up menu

Working example:
See here: viewtopic.php?p=192020#p192020

What I want to do:
Make the icon dynamic by replacing the static icon description, e.g. ":dark" after the pipe ("|") with an alias variable, like "<@iconname>".

Problem:
Although it does work, to make the normal caption text dynamic with an alias variable, it does not work to do so for the icon part. Even though the alias is resolved to the same string as if I had typed it without an alias, XY refuses to turn it into an icon. Instead, XY either draws a "?" icon, a grey icon, or no icon at all, depending on the exact implementation of the alias in the caption string.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Dynamic icon in CTB context menu caption with alias not working

Post by admin »

Hm. Give me the complete steps including the alias definitions.

autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Re: Dynamic icon in CTB context menu caption with alias not working

Post by autocart »

Ähmm, may I please say: If you would read the first post...
Its all there in the CTB snippet.
If you want to try it out, just make a new CTB and paste the snippet.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Dynamic icon in CTB context menu caption with alias not working

Post by admin »

Whoops :whistle:

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Dynamic icon in CTB context menu caption with alias not working

Post by admin »

Next beta will show your dynamic icons.


autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Re: Dynamic icon in CTB context menu caption with alias not working

Post by autocart »

Thanks, but not perfect yet:
The context menu needs to be called two times, as it seems, before the icon gets updated.
The first time, ofc, that icon toggling entry must not be selected but the context menu discareded.

If I use that context menu in a "normal" way and right click each time only one time and select that entry immedeately, then the icon does update always one click too late, resulting in an exactly reversed icon toggle -> When it should show "off" it shows "on" and vice versa.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Dynamic icon in CTB context menu caption with alias not working

Post by admin »

In the next beta it will work if you put the "_Initialize" before the other code:

Code: Select all

"_Initialize"
 if (tweak("SkipBrowseEvents")==1) {
  goto "@autocart_label_ToggleLocationCEAs=[Location CEAs are OFF]: Activate";
  goto "@autocart_label_ToggleLocationCEAs_Icon=:dark";
 } else {
  goto "@autocart_label_ToggleLocationCEAs=[Location CEAs are ON]: Deactivate";
  goto "@autocart_label_ToggleLocationCEAs_Icon=:sync";
 }
"<@autocart_label_ToggleLocationCEAs>|<@autocart_label_ToggleLocationCEAs_Icon>"
 if (tweak("SkipBrowseEvents") == 1) {
  tweak("SkipBrowseEvents", 0);
 } else {
  tweak("SkipBrowseEvents", 1);
 }


klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Dynamic icon in CTB context menu caption with alias not working

Post by klownboy »

I tried to do exactly the same using perm variable and got the same result as using aliases. The icon will work but it's not the latest permed value in the script. Try this on script to check either in a CTB or simply running the script. Perms were made to work in a script title as shown quite awhile ago. but not in this case. The perm icon set in "_Initialize" is not the updated one which should be used in the title line.

Code: Select all

"_Initialize"; //step;
  //unset $autocart_label_ToggleLocationCEAs, $autocart_label_ToggleLocationCEAs_Icon;
  if (tweak("SkipBrowseEvents")=="1") {
   perm $autocart_label_ToggleLocationCEAs="[Location CEAs are OFF]: Activate";
   perm $autocart_label_ToggleLocationCEAs_Icon=":" . "exitnosave";  // tried this as well  ":exitnosave";
    } else {
    perm $autocart_label_ToggleLocationCEAs="[Location CEAs are ON]: Deactivate";
    perm $autocart_label_ToggleLocationCEAs_Icon=":" . "select"; 
   }
   writePV;

"Of mice and Men|:cfi"
  status "Hello Lenni";
  end 1;

"$autocart_label_ToggleLocationCEAs|$autocart_label_ToggleLocationCEAs_Icon";
   if (tweak("SkipBrowseEvents") == "1") {
    tweak("SkipBrowseEvents", "0");
   } else {
    tweak("SkipBrowseEvents", "1");
   }
  end 1;
   unset $autocart_label_ToggleLocationCEAs, $autocart_label_ToggleLocationCEAs_Icon;
EDIT: Don, I just noticed your last entry about putting "_Initialize" before other code. So that in theory should make the above "perm" (vs alias) version work as well. Correct?
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Dynamic icon in CTB context menu caption with alias not working

Post by admin »

You will tell me... :)

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Dynamic icon in CTB context menu caption with alias not working

Post by klownboy »

admin wrote: 25 Oct 2021 15:08 You will tell me...
Unfortunately that script I posted above using perm variables still doesn't work with beta v22.30.0210. The perm icon is not updated to the new value in "_Initialize". The title itself, variable $autocart_label_ToggleLocationCEAs is updated, but the icon $autocart_label_ToggleLocationCEAs_Icon is not. So it appears what's on the right side of the "|" is not updated.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Re: Dynamic icon in CTB context menu caption with alias not working

Post by autocart »

klownboy wrote: 25 Oct 2021 15:29
admin wrote: 25 Oct 2021 15:08 You will tell me...
Unfortunately that script I posted above using perm variables still doesn't work with beta v22.30.0210. The perm icon is not updated to the new value in "_Initialize". The title itself, variable $autocart_label_ToggleLocationCEAs is updated, but the icon $autocart_label_ToggleLocationCEAs_Icon is not. So it appears what's on the right side of the "|" is not updated.
Yes, Don wrote his announcement after 0210.

Post Reply