customize context menu for float menu button

currently when right click any floating menu, a context menu as below shows. Is there a way to customize it that also depends upon on which button item the right click happens?

image

4.790 adds a right click action category:

1 Like

Do you suggest me to use the right click action to show a customized context menu or another floating menu as context menu?
but

  1. the button is dynamically generated by the menu level script, how to add a right click action for the dynamic button?
  2. My purpose is for the win10 taskbar buttons, I need to transfer the window key or ID and app name that the button presents to the right click function, so I can implement such as "hide the window" or "quit the app" etc., is it possible to do that now?

In theory it is possible (requires BTT 4.794). You can define separate standard and rightclick actions like in this example. Here the leftclick would type "a" and the right click would first set a variable to some value and then paste the value of that variable.

 {
      title: "test item 0",
      actions: {
        standard: "keyboard::0",
        rightclick: {
          setvariable: {
            name: "the_variable",
            value: "some text",
          },
          btt: "paste_text",
          args: {
            text: "(BTT)@variable:the_variable(BTT)",
            insert_by_pasting: true,
          },
        },
      },
    }

The easiest way to achieve a custom context menu would be to first set a variable with your required information, then call a named trigger that shows a context menu. In that context menu you can then trigger actions that make use of your variable.

Something like this:

async function retrieveJSON() {
  let items = [
    {
      title: "test item 0",
      actions: {
        standard: "keyboard::0",
        rightclick: {
          setvariable: {
            name: "the_variable",
            value: "some variable content",
          },
          named: "the_name_of_your_named_trigger"

        },
      },
    }
  ];

  return JSON.stringify(items);
}

Thank you for the suggestion. It is a valid solution. Now I can show context menu and I can use your suggested way to transfer app related info.
The next question is, for hide window (like command+W does) and quit app(like command+Q does), what is the available javascript function BTT provides, like the one previously for switching windows
BTTActions.activateWindowWithNumberRaiseAppID(kCGWindowNumber, true,KCGWindowOwnerPID})

btw, i already verified that i can use get_string_variable to get the variable value rightclick action set, in my case i will store kCGWindowNumber and kCGWindowOwnerPID