Disable ctrl-x on a GoSimpleNode


Is there a away to disable cutting a node from a GoDocument? I want to allow the user to use the delete key to remove nodes, but not cntrl-x.

Thanks for any help!



Did you want to disallow both Edit | Cut and Control-X? Do you want to permit copying of the node? If YES and NO, respectively, you can just disable copying by setting AllowCopy to false on the view or on the document.
If you just want to disable Control-X, you can install an instance of a subclass of GoToolManager as the GoView.DefaultTool. Just override GoToolManager.DoKeyDown() to check for .LastInput.Control and also .LastInput.Key being equal to Keys.X. If it’s not Control-X, call the base method.
public class MyToolManager : GoToolManager {
public MyToolManager(GoView v) : base(v) {}
public override void DoKeyDown() {
if (!this.LastInput.Control || this.LastInput.Key != Keys.X)
and when initializing your view:
goView1.DefaultTool = new MyToolManager(goView1);
goView1.Tool = goView1.DefaultTool;
Remember that this just intercepts Control-X; the Edit | Cut menu will still work, and calls to GoView.EditCut() will still work in the normal circumstances.


Thanks Walter, that worked perfectly.