Custom context menu for list's whitespace

Discuss and share scripts and script files...
John_C
Posts: 336
Joined: 16 May 2018 20:04

Custom context menu for list's whitespace

Post by John_C »

How does such context menu could be created:

viewtopic.php?f=3&t=18674#p157659

?

Here is what I have currently:

Code: Select all

"Paste" #202
"Undo" #203
"Redo" #204
"Refresh" #1001
"New Shortcut" #241
"New Items (should be expandable. How?)" #240

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend »

By using

Code: Select all

popupnested()
and either manually stored items for "New items" or by parsing them in their location...
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C »

highend wrote:By using

Code: Select all

popupnested()
and either manually stored items for "New items" or by parsing them in their location...
I have tried different examples from docs, but it works slightly different compared to the linked image. On the image, as you can see, the item on first menu is already expandable. In my case, it doesn't. Here is my current code:

Code: Select all

"Paste" #202
"Undo" #203
"Redo" #204
"Refresh" #1001
"New Shortcut" #241
"New" // #240
    $menu = <<<MENU
        Top;;:paper;1
            Sub;;;4
            Sub
                Sub2;;*.ini
                Sub2
                Sub2;;;2
        Top;;<xy>
    MENU;
    text popupnested($menu);

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend »

Ofc you need to arrange these leading items in the popupnested() menu as well?
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C »

highend wrote:Ofc you need to arrange these leading items in the popupnested() menu as well?
Well, here is updated version. Much cleaner:

Code: Select all

$menu =
    <<<MENU
        Paste;#202;:paste
        Undo;#203;:undo
        Redo;#204;:redo
        Refresh;#1001;:refresh
        New Items;#240
            Foo
            Bar
    MENU;
    popupnested($menu);
Now I trying to understand how to add "new items" in place of "Foo" and "Bar". Here is what I mean:
menu.png
menu.png (16.01 KiB) Viewed 2894 times
"Parsing them in their location" as you said - I understand what it mean, but I don't understand how to write it in code :lol:

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Custom context menu for list's whitespace

Post by Filehero »

Examples for SC new().

Code: Select all

new("NewFolder", "dir");
new("file.txt");

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend »

and the only thing necessary to execute the returned menu entry is

Code: Select all

 eval()
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C »

Filehero wrote:Examples for SC new().

Code: Select all

new("NewFolder", "dir");
new("file.txt");
Could you please show how to use it together with my code?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend »

Read the docs for

Code: Select all

popupmenu()
. It explains how the necessary parts are put together
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C »

highend wrote:Read the docs for

Code: Select all

popupmenu()
. It explains how the necessary parts are put together
I already read, but can't understand. :veryconfused:

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend »

What? You're already using the necessary structure in your other items?

Code: Select all

Paste;#202;:paste
caption;DATA;icon
What to use for DATA for an item was posted and how to execute that returned DATA stuff was also posted...

1+1=?
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C »

highend wrote:What? You're already using the necessary structure in your other items?

Code: Select all

Paste;#202;:paste
caption;DATA;icon
What to use for DATA for an item was posted and how to execute that returned DATA stuff was also posted...

1+1=?
I'm not a programmer. If it's hard to post a working solution? I see your code, but it works for "Paste" button. I already have working "Paste" button. I'm trying to understand how to add "new folder" and "new text file" instead of "Foo" and "Bar".

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C »

highend wrote:What? You're already using the necessary structure in your other items?

Code: Select all

Paste;#202;:paste
caption;DATA;icon
What to use for DATA for an item was posted and how to execute that returned DATA stuff was also posted...

1+1=?
For example, I tried this:

Code: Select all

$menu =
    <<<MENU
        Paste;#202;:paste
        Undo;#203;:undo
        Redo;#204;:redo
        Refresh;#1001;:refresh
        New Items
            Foo;new("NewFolder", "dir"));
            Bar;new("file.txt")
    MENU;
    popupnested($menu);
    eval($menu);
It doesn't work for me.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend »

You need to assign popupnested()'s return value to a variable and eval that or do it directly in one go.
Atm the menu is displayed but what it returns isn't stored / nor eval()'d

Code: Select all

eval(popupnested($menu));
or

Code: Select all

$selected = popupnested($menu);
eval($selected);
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C »

highend wrote:...
Thank you very much, it works perfectly! :beer:

Post Reply