Cut/Copy/Paste issues

Hello all,

I’m using JGo SWT 5.15 in an Eclipse plug-in and I’m having an issue with clipboard functions (Cut, copy, paste). When I have text selected, and do Edit->Cut, it cuts the selected node, rather than the selected text. I’ve noticed the same problem on the Demo1 app as well.

In the demo app, try this:

  1. Double click on the “general node” text, as if you were going to rename the node’s label.
  2. Select all of the “general node” text.
  3. Select the Edit->Cut menu item.
  4. Notice that the node is Cut, not the selected text.
  5. Select the Edit->Paste menu item.
  6. Note that the node has now been pasted back.

It seems as if the target of the Copy/Cut/Paste/Delete actions are always nodes, even if the current focus/selection is a label.

Any help or suggestions?


I suspect that’s because the accelerator keys are causing the SelectionListeners to be called, which operate directly on the JGoView.
If you run BasicApp, you will note that the routing of the control keys is working the way you want.

Thanks walter, BasicApp indeed does do what you say. I have modified my code to follow the example given, and the CTRL-X/C/V keystrokes work as they should. However, I still have one issue; BasicApp does not have a menubar with Edit->Cut/Copy/Paste menu items.

Perhaps this is a mixed JGo and Eclipse question, but what would be the proper way to create actions for contributing to the Edit menu that has the proper behavior? i.e., an action that does copy’ing of text when text is selected/focused and copy’ing of JGo objects when an object is selected/focused.

There shouldn’t be any problem with having a menu bar and an Edit menu – it’s just defining accelerator keys that’s causing the problem, since they get preempted by the form. It should be possible to have the form reroute those keyboard events to the appropriate control (i.e. when JGoView.getEditControl() returns a non-null value), but off hand I don’t remember the way to do that in SWT.