Any way to make popupmenu() item "disabled"?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
eil
Posts: 1864
Joined: 13 Jan 2011 19:44

Any way to make popupmenu() item "disabled"?

Post by eil »

Decided to swap the default List context menu on white space with own smaller re-arranged + icons version. It was a pleasant surprise that if popupmenu() is used with IDs of commands and buttons, those are fully resembling the usual ones = like they same show the shortkeys and commands IDs. But there came one inconsistency: with default menu if nothing is selected and context menu called, say Copy/Append/Compare items are disabled, but when a scripted version is called - Copy is ready to be used, though actually it will do nothing.
Example code:

Code: Select all

popupnested("Copy Commands| #101;;:copypath| #102|#201;;:copy|Dual Pane Commands| #800;;:dp| #801| #802"); // mixed commands nested with toolbar icons
If that would be a fully custom scripted menu with no internal commands i'd say "oh well, there must be lots of checked incorporated for such situation", but since popupmenu() is already pretty good at using native commands, maybe there is a way to "forcefully disable" some popupmenu() items while keeping them in menu? Or maybe it's just overlooked/bug, and popupmenu() ought to have such commands same disabled, as it works in usual.?
Win 7 SP1 x64 100% 1366x768|1900x1080

jupe
Posts: 3446
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Any way to make popupmenu() item "disabled"?

Post by jupe »

You can do it manually something like this:

Code: Select all

$s = <selitem> ? 0:4; popupnested("Copy Commands| #101;;:copypath| #102|#201;;:copy;$s|Dual Pane Commands| #800;;:dp| #801| #802"); // mixed commands nested with toolbar icons
Don will have to answer if it could be done automatically.

eil
Posts: 1864
Joined: 13 Jan 2011 19:44

Re: Any way to make popupmenu() item "disabled"?

Post by eil »

Thank you for hint, <selitem> check as an argument for item is an unexpected trick for me.
Hope Don may notice this and clarify why popupmenu() + #ID can visually fully emulate usual menu items, but doesn't properly check if item should be available.
Win 7 SP1 x64 100% 1366x768|1900x1080

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

Re: Any way to make popupmenu() item "disabled"?

Post by admin »

jupe's solution is the way to go. It's not the job of the script language to do all your work. :)

eil
Posts: 1864
Joined: 13 Jan 2011 19:44

Re: Any way to make popupmenu() item "disabled"?

Post by eil »

admin wrote: 18 Jun 2024 13:03 It's not the job of the script language to do all your work. :)
Surely it isn't, it just caught me "surprised" that commands added to my scripted menu via IDs look totally like native ones = showing keyboard shortcut and the IDs too. So it's a little frustrating that visually such ID-added items in scripted menu look totally like native ones, but they actually don't work like native ones.
Win 7 SP1 x64 100% 1366x768|1900x1080

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

Re: Any way to make popupmenu() item "disabled"?

Post by admin »

When you open a main menu, a lot of things happen in the background between when you click and when the menu actually opens. This stuff does not belong into scripting.

Post Reply