Page 1 of 1
Any way to make popupmenu() item "disabled"?
Posted: 16 Jun 2024 01:11
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.?
Re: Any way to make popupmenu() item "disabled"?
Posted: 16 Jun 2024 02:08
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.
Re: Any way to make popupmenu() item "disabled"?
Posted: 18 Jun 2024 12:43
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.
Re: Any way to make popupmenu() item "disabled"?
Posted: 18 Jun 2024 13:03
by admin
jupe's solution is the way to go. It's not the job of the script language to do all your work.

Re: Any way to make popupmenu() item "disabled"?
Posted: 18 Jun 2024 18:16
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.
Re: Any way to make popupmenu() item "disabled"?
Posted: 18 Jun 2024 18:40
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.