Custom context menu for list's whitespace

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

Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 21:06

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: 8153
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend » 29 Aug 2018 21:18

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 or highend (at) web (dot) de

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

Re: Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 21:42

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: 8153
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend » 29 Aug 2018 21:47

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 or highend (at) web (dot) de

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

Re: Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 22:18

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 768 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: 2283
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Custom context menu for list's whitespace

Post by Filehero » 29 Aug 2018 22:22

Examples for SC new().

Code: Select all

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

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

Re: Custom context menu for list's whitespace

Post by highend » 29 Aug 2018 22:24

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 or highend (at) web (dot) de

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

Re: Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 22:29

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: 8153
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend » 29 Aug 2018 22:33

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 or highend (at) web (dot) de

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

Re: Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 22:47

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: 8153
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend » 29 Aug 2018 22:49

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 or highend (at) web (dot) de

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

Re: Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 22:55

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: 140
Joined: 16 May 2018 20:04

Re: Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 23:09

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: 8153
Joined: 06 Feb 2011 00:33

Re: Custom context menu for list's whitespace

Post by highend » 29 Aug 2018 23:12

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 or highend (at) web (dot) de

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

Re: Custom context menu for list's whitespace

Post by John_C » 29 Aug 2018 23:17

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

Post Reply