Cut,Copy,Paste menus

Ron rbarber at yhb.att.ne.jp
Sun Feb 2 05:25:01 EST 2003


Hi Jeanne

Thanks for replying. I don't mean to beat this thread to death but I still
don't know why I can't use the cmdkey to operate the CCP set.
 
> At 11:43 PM -0800 1/31/03, Ron wrote:
>> Where should scripts that control the enabling/disabling of menuitems be
>> placed? Obviously, the menu's mousedown message is not the place because it
>> is not activated until I click in the menubar.
> 
> Actually, the best place is a mouseDown handler in the script of the menu
> bar group.
> 
> Why in the mouseDown handler? Because mouseDown is sent before the menu is
> displayed, so it's the best place to put menu changes that need to be done
> "just in time".

Well, that's what I thought. In fact I do just that with my format menu that
gets the textfont,textstyle, textcolor, textsize and places a check by the
appropriate menuitem of the menu according to the current selectedtext.

> Why in the group? Because on Mac OS and OS X systems, the menu doesn't get
> a mouseDown message, but the group does.

I'm using a Mac primarily so this is the way I've approached it.

So, if I want to disable the copy menuitem when no text is selected and
enable it when text is selected, where should I put the controls for this?

There seem to be several choices.
On openfield:.
On mousedown of the menubar group.
On selectionchanged.


Currently, I enable 'copy' when the menubar group gets a mousedown message,
just as you suggested. eg On mousedown and text is selected, then enable
'copy'. This works fine since it is 'just in time'. However, let's say I
open a fld, then select some text. The 'copy' menu should now be enabled,
but since I have not clicked in the menubar, the 'copy' menu is still in its
default state of disabled. Thus when the cmdkey is sent to the menubar,
nothing happens. 

Jan suggested trying selectionchanged. So, I put the following handler in a
cd with a text fld.
on selectionchanged
  if the selectedtext is not "" then
    enable menuitem 2 of menu 2 --the copy menuitem
  else
    disable menuitem 2 of menu 2
  end if
  pass selectionchanged
end selectionchanged

The menus stop responding to cmdkeys. Without this script, they respond to
cmdkeys if the menuitem has not been disabled. But disabling and then
enabling them seem to kill the response to cmdkeys. This is using 1.1.1 on
OS 9.2.1

Is my thinking or method incorrect?

Thanks
Ron




More information about the use-livecode mailing list