Any self-respecting menu bar disables the Edit menuItems cut/copy/paste under certain conditions. I've been having two problems re-enabling them. Any help would be much appreciated. (Win 7, LC 6.5.2)

The LiveCode User Guide suggests the disable/enable code go in the grp "Menubar 1" script. "If you want to dynamically change a menu's contents with a mouseDown handler at the time the menu is displayed, you must place the mouseDown handler in the group's script. When a menu button is being displayed in the Mac OS menu bar, it does not receive mouseDown messages, but its group does."

Problem1: There may be something wrong with the enable command. If I use the Edit menu to cut and paste text, immediately select new text, I can't use the Edit menu because cut/copy menuItems are still disabled.

After Edit menuItems are disabled, they fail to re-enable using the pull-down menu. This seems to be fixed by placing a disable command before the enable commands. Strange. No help with an additional enable command, wait 0 secs with messages, re-wording the enable commands with 'menu "Edit" of me', or replacing the disable/enable commands with "(".

Problem2: After the fix for problem1, if I use the Edit menu to cut and paste text, immediately select new text, I can't cut with ctrl-x. Using the menu doesn't send a mouseLeave message to re-enable menuItems for keyboard equivilents. No fix.

Typically all the commands are done in the mouseDown handler. (I'm a little surprised to learn that mouseleave is supported in menus, but probably that's because I develop on a Mac where menus behave differently.)

What I always do is enable everything, and then disable the parts I don't want. In your example:

Thanks to Jacque's comments I removed the mouseLeave handler from the grp "Menubar 1" script and placed a commandKeyDown handler in the stack script to restore edit menu keyboard equivilents, which as I understand is cross-platform compatible. This fixed both problems.

I added Undo to the edit menu, and fixed a small problem with the menu bar width following the stack width in Geometry manager. I think everything works on Win 7, LC 6.5.2. A public stack with a pull-down menu is quite rare. I searched the forum and revOnline and found only two, both from Jacque. This one is free for anyone to use in their projects.

TerryL wrote:Thanks to Jacque's comments I removed the mouseLeave handler from the grp "Menubar 1" script and placed a commandKeyDown handler in the stack script to restore edit menu keyboard equivilents, which as I understand is cross-platform compatible. This fixed both problems.

If memory serves, you shouldn't need to add a commandKeydown message as command keys which can trigger menu items cause a mouseDown to go to the menuGroup before the menus are rendered, thus allowing us to centralize menu updating code in one mouseDown handler in the menu group.

Richard Gaskin
Community volunteer LiveCode Community LiaisonLiveCode development, training, and consulting services: Fourth World Systems:http://FourthWorld.comLiveCode User Group on Facebook :http://FaceBook.com/groups/LiveCodeUsers/

I re-tested the disabled Edit menuItems at Richard's suggestion. The commandKeyDown handler in the stack script IS necessary. If the cut, copy, or paste menuItems are disabled, their keyboard equivalents are also disabled and remain disabled until the mouseDown handler in the menu bar group script re-enables them. For example, with the commandKeyDown handler commented out, cut and paste text with the Edit menu. Now text can't be cut or copied with the keyboard unless the commandKeyDown handler is restored.

The ctrl-A (select all) and ctrl-Z (undo) though were unnecessary and now removed from the commandKeyDown handler in the updated attachment. Thanks for looking over the code Richard. It really does help make it better. Terry