Copy/Cut/Paste Edit Menu Questions?

Garrett Hylltun garrett at paraboliclogic.com
Fri Apr 21 15:25:41 EDT 2006


David Burgun wrote:
> Hi,
> 
> I've noticed that the copy/cut/paste commands work automatically when 
> you use the Command-Key short cuts, e.g. if you have an Text Field and 
> you select the text within it, you can copy or paste into that field. 
> This seems to work in the IDE and in the Standalone. My first question 
> is how/where is this action handled? Can I stop this action happening on 
> certain fields?

In the docs, check out

* copyKey message
* cutKey message
* pasteKey message

Example:

on cutKey
   cut
end cutKey

Also see the following in the docs:

* cut
* copy
* paste

I imagine if you place these message handlers in the field's code and 
put nothing in the handlers that the events won't take place.

> My second question is, how do you handle these commands when selected 
 > from the Edit Menu?

use the the following (using either IF statements or CASE statements) 
handler in the code for the menu object:

on menuPick varSelected
   if varSelected is "Cut" then
     focus field "editfieldnamehere"
     cut
   else if varSelected is "Copy" then
     focus field "editfieldnamehere"
     copy
   else if varSelected is "Paste" then
     focus field "editfieldnamehere"
     paste
   end if
end menuPick

 > from the Edit Menu? And how can you disable/enable the edit menu items
 > depending on which control has been selected?

* disableMenu command

I'm still a bit of newbie to Rev, so the above may not be totally 
correct.  If not, I'm sure someone will drop in and correct my errors so 
that you don't repeat my errors in your code.  :-)

-Garrett



More information about the use-livecode mailing list