I am doing some custom copy and pasting in my application. I am not using the default support provided by GoDiagram. I would like to trap the Ctrl-C,X,v & Del key presses. To achieve this I am overriding EditCut/Copy/Past/Delete methods.
However, in my app these methods are not getting called on Ctrl & Del events. CanCopyObjects and AllowCopy are true.
Are there are any properties etc that are to be set so that the GoView catches the ctrl and del key events used for cut/copy/pasting?
Should I override PreProcessMessage to trap the Ctrl C, etc key presses?
I’m not sure what you mean by “Ctrl & Del events”. By default the Delete key is interpreted by the GoToolManager to call GoView.EditDelete, even when the Ctrl key is held down. The other standard Ctrl-C, Ctrl-X, Ctrl-V key commands call the corresponding GoView methods, as you listed and as documented. So if you have indeed overridden those methods in your view, they will get called.
GoView passes all mouse and key events (in canonical form as GoInputEventArgs) to the current tool, calling the IGoTool methods from the correspondingly named method in GoView. For example, an input keyboard event in Windows Forms calls GoView.OnKeyDown, which constructs a GoInputEventArgs and then calls GoView.DoKeyDown, which in turn just calls this.Tool.DoKeyDown(). [The standardization of input events and the GoView.DoKeyDown method help support common code between the different .NET platforms on which GoDiagram is implemented.]
You can certainly do all your own key event handling if you want, but that should rarely be needed, and is obviously not desired if you want to use some or all of the standard functionality.
Try overriding one of the GoView.Edit… methods in one of the sample applications, just to convince yourself that that should work.
Actually the Ctrl C,V etc key events are going to the main form which is hosting the various views. Hence I have the find the current active child and delegate the Edit… calls to them (like in Demo1)
Also, for drag copying which event should I trap… GoView.SelectionCopied ?
Yes, the table in chapter 5 of the User Guide describes all of the methods that are called when the GoToolManager handles keyboard input.
Well, obviously drag-copying isn’t a keyboard event action, so I don’t see how that’s relevant to this discussion. But yes, the GoView.SelectionCopied event is raised just after the copy has occurred. And the same goes for the moving of objects with the GoView.SelectionMoved event.