Clearing get("trigger", "mousebtn")

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Clearing get("trigger", "mousebtn")

Post by klownboy »

Simple script below which brings up favorite folders on left click of CTB and Favorite files on a right click. I ran into an issue in a more complicated script so I made this uncomplicated version for testing. What I see is, if I bring up one Fav menu on a left click (i.e., the menu is showing) and then go on to right click to bring up the other nmenu, the same left click menu is displayed. I'm aware of the get trigger statement below which is saying trigger is cleared after the script is processed. That's fine, but isn't there someway to have it cleared as soon as the script is re-invoked (by reclicking the CTB). Can't we get the previous trigger cleared at that point? Sure it works as it should if I click outside the menu, and then re-click the CTB, but can't we get the trigger cleared when the CTB is re-clicked (i.e., consider any reinvoking of the script as the script being completely processed and therefore the trigger value from the previous run is cleared? Obviously unsetting $trigger has no affect, even if I do it just prior to invoking the CID. Thanks. Maybe this should be in Wishes.
- The <get trigger> variable is cleared after the script is processed.
- Currently implemented only for Custom Toolbar Buttons.

Code: Select all

	unset $trigger;
		$trigger = get('trigger', 'mousebtn');
	if($trigger == "1") {
		#550;}
	elseif($trigger == "2") {
		#564;}
	unset $trigger;
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: Clearing get("trigger", "mousebtn")

Post by admin »

Show the button definition as snippet (right-click the Clear button in the Edit User Button dialog). Makes it easier.

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

Re: Clearing get("trigger", "mousebtn")

Post by klownboy »

Okay Don, I forget about snippets.

Code: Select all

Snip: CTB 1
  XYplorer 24.20.0302, 3/20/2023 10:03:19 AM
Action
  NewUserButton
Name
  test
Icon
  
ScriptL
  unset $trigger;
   $trigger = get('trigger', 'mousebtn');
    if($trigger == "1") {
       #550;}
    elseif($trigger == "2") {
       #564;}
    unset $trigger;
ScriptR
   unset $trigger;
   $trigger = get('trigger', 'mousebtn');
    if($trigger == "1") {
       #550;}
    elseif($trigger == "2") {
       #564;}
    unset $trigger;
ScriptM
  
FireClick
  0

Edit: I added the script to the left/right click actions instead of referring to a script file to make it a bit easier.
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: Clearing get("trigger", "mousebtn")

Post by admin »

Right-click looks like this here:
2023-03-20_151331.png
2023-03-20_151331.png (2.38 KiB) Viewed 228 times
Is that expected?

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

Re: Clearing get("trigger", "mousebtn")

Post by klownboy »

It looks like you may not have the tweak set for no menu on right click.
CTBNoRClickDefaultCommands=1
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: Clearing get("trigger", "mousebtn")

Post by admin »

Ah.

But the button seems to work now: left-click folder, right-click files. What is the problem?

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

Re: Clearing get("trigger", "mousebtn")

Post by klownboy »

Well, it's explained in the first post, but my issue is, the trigger value does not clear in the following instance. When you left click the CTB, the menu is displayed. If while the menu is still displayed you then right click the CTB, the trigger is not reset, and you get the same left click menu. I'm aware of the Help words that state the "trigger value is cleared after the script is processed", but it would be nice if upon reinvoking the script (by clicking the CTB) that would also clear the trigger value. Currently it does not. Say you simply clicked the wrong button (left instead of right), it be better if you could simply re-click the right button to get the proper menu, but instead now you have to click outside the menu then re-click the CTB with the right button.
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: Clearing get("trigger", "mousebtn")

Post by admin »

klownboy wrote: 20 Mar 2023 15:46 If while the menu is still displayed you then right click the CTB, the trigger is not reset, and you get the same left click menu.
Not here.

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

Re: Clearing get("trigger", "mousebtn")

Post by klownboy »

If I start off by right clicking and bring up the Favorite Files menu, and with that still displayed, left-click to bring up the favorite folders menu, the proper left click (Favorite Folders) menu displays.

If I do the opposite and bring up the left-click Favorite Folders menu first, and then right click the same favorite folders menu is displayed again. So, from right to left it seems to work the way I want but not left to right. So, what could be causing that to happen?

I figured it out (via stepping). It's AHK script detecting the right click in a menu [urlhttps://www.xyplorer.com/xyfc/viewtopic.php?t=18062[/url]. I see the perm value $rmb=1 come up when I right click the CTB which is telling me that the AHK script is seeing the context menu up for the left click menu and is assuming I'm right click the menu so is sending a left click.
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: Clearing get("trigger", "mousebtn")

Post by admin »

Sorry, but I have no time to debug anything that involves AHK. From my POV that's hacking. Don't post stuff like this as XY related reports. It's not. :masked:

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

Re: Clearing get("trigger", "mousebtn")

Post by klownboy »

admin wrote: 20 Mar 2023 17:06 Don't post stuff like this as XY related reports. It's not
Well, I apologize, but I didn't know it had anything to do with AHK until you said, it worked for you. I thought it was the fact that "trigger" wasn't clearing. I don't want you to debug anything. I'll disable that AHK script.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply