Dimming a MENU, not a MENU ITEM

Hey gang, haven’t been around for a while, thought I’d post a question as my way of saying “hello.”

Is it possible to dim a menu, not a menu item? The menu definition doesn’t contain a “state” like the menu item does.

I’ve got an AS Studio app that I’m working on, and I want to disable some menus when different windows are the front window because those menus don’t apply to those windows. But every time I try, I get NSRecieverError 4(1). I’ve set the windows to send a became main event, and here’s one of the handlers (there’s one in the main script and one in the document script - one turns it on, the other turns it off, so they’re basically the same code):


on became main theObject
	(*disable menus when document is main*)
	set the state of menu item "Edit" of the main menu to 0
end became main

Model: G4 tower named “Morpheus” (466mhz, 384mb)
AppleScript: 1.10
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Oh, and I’ve also tried:


on became main theObject
	(*disable menus when document is main*)
	set the enabled of menu item "Edit" of the main menu to false
end became main

Hi Kevin,

enabled is the right thing,
but there’s one reference missing:

set the enabled of menu item “Edit” of menu “File” of main menu to false

Won’t that just dim an item on the File menu? I need to dim the Edit menu out, so that it is not usable at all.

this is not possible.
I’ve never seen a dimmed menu of an active application.
You can either dim every single element or delete and (re)create menus

Offhand, I have to agree with Stefan; I don’t think this is possible. If you really need this behavior, I would try something like this:

set enabled of menu items of menu "Edit" of main menu to false

I guess you’re right, I’ve not seen a disabled menu in OS X either, now that you mention it. I must be thinking of the older Mac OS’s, they used to dim menus (like the Edit menu) if it wasn’t applicable.

Thanks guys!

Greetings,

No, it’s not inherently possible to “dim” a main menu item. Something like…

tell menu item "File" of main menu to set enabled to false

…DOES disable the menu item, though. Note that you must set “File” as the AS name for the actual menu item that the ‘File submenu’ is attached to, and not to the submenu that contains all of the items. That’s an easy thing to miss. Unfortunately, it does not SHOW that it’s disabled by dimming it. All of it’s items become disabled and dimmed themselves, but the menu item title stays black.

There might be a way to mess with the title or attributed title by using cocoa or carbon. The only other option I see would be to create a custom image out of your title’s text and swapping out a different colored version of the image based on the state. These are ugly hacks, and are obviously outside the human interface guidelines. Unless you’re creating a status item or other sort of indicator menu item where visual notification would be desirable, I wouldn’t go too much further with this.

Take care,
j

Thanks, Jobu, I agree and have settled for just dimming the submenu items. I don’t know why I had an image stuck in my head of a dimmed menu title? Where did THAT come from? :rolleyes:

Well if your app is active but no documents are open then a menu might not be enabled. Like in Photoshop, if no doc is open, then the IMAGE, SELECT, and FILTER menus are greyed out. I’m looking at CS2 right now.