cut-copy-paste functionality

How do you assign the system-wide cut-copy-paste functionality to a button? or a contextual menu? Not asking how to make the contextual menu or how to activate it, but rather what call should be made to get the same functionality that you get from the edit menu when you choose cut-copy-paste from there?

for contextual menu you can clone the menu

base.Append EditCut.Clone base.Append EditCopy.Clone base.Append EditPaste.Clone

In a button you can use the ClipBoard object.

See http://documentation.xojo.com/index.php/clipboard

Well, I could use the clipboard object but it seems to me that that would be a reinvention of the wheel, so to speak. When you start a new desktop project it has the edit menu with cut-copy-paste already rolled into it… and it just works, and that is awesome! I don’t want to reinvent that process, I would rather tap in to it by saying something like… “when I push this button, do MenuItem EditCut”.

For the contextual menu, Axel has it… and thank you for that Axel. That took me down a whole road I was not expecting regarding cloning of menu items etc.

It is not possible in Xojo to summon built in menu handlers that way.

Maybe through declares…

OK. There might be a way.

In Windows, you can plug in keystrokes in the system buffer. So you can send Ctrl-C, Ctrl-X and Xtrl-V.

See https://forum.xojo.com/6009-sendkey-function/0

In Mac OS X, AppleScript does that as well. Just Keystroke your own app. However, using that technique in a program destined to be posted in the Mac App Store will likely get it rejected.

[quote=205481:@Christopher Raab]Well, I could use the clipboard object but it seems to me that that would be a reinvention of the wheel, so to speak. When you start a new desktop project it has the edit menu with cut-copy-paste already rolled into it… and it just works, and that is awesome! I don’t want to reinvent that process, I would rather tap in to it by saying something like… “when I push this button, do MenuItem EditCut”.

For the contextual menu, Axel has it… and thank you for that Axel. That took me down a whole road I was not expecting regarding cloning of menu items etc.[/quote]
FWIW, you’re only talking about two lines of code to use a Clipboard object:

dim CB as new Clipboard CB.SetText "hello world"

[quote=206053:@Greg O’Lone]FWIW, you’re only talking about two lines of code to use a Clipboard object:

dim CB as new Clipboard CB.SetText "hello world"[/quote]

CB.Close :wink:

Or just let it go out of scope

And if -for unknow reason - your code is more than two or three lines, you can add it to a Module (etc.) and call the method from the handler, a button, etc.