This project is read-only.

Copy/Paste between documents bug

Sep 5, 2008 at 5:43 AM
Edited Sep 5, 2008 at 5:55 AM
One other bug report.

Open 2 documents. In the first doc, select some text and do Ctrl-C to copy. Now hit Shift-Tab to switch to the second doc, click anywhere and do Ctrl-V to paste the text. The text will be pasted into first doc and not on the active doc. This happens 100% of the time and it only happen if you use Shift-Tab; not when you click on the tab to select the second document.

I have no idea why it's this way but it drive me crazy. Almost certain it's the WeifenLuo.WinFormsUI.Docking component and not ScintillaNet but still like to report it.
Sep 8, 2008 at 8:54 PM
I'd imagine so. I've been able to reproduce it but at the moment I don't have any good ideas why. I'll probably have to trace the Windows messages around...
Feb 10, 2009 at 5:32 PM
I'd really like to fix this bug myself if you could give me some pointers on how to approach it. I've looked at Commands.cs and seen that it took over the task of processing all commands. So maybe this is where the bug happens but i could not figure out what it was that cause Scintilla to not getting the focus of the keystrokes. The active doc is showing so that means the DockPanel and DockContent know they're active, but why would the Scintilla control doesn't?
Feb 10, 2009 at 5:41 PM
The first thing I would check on is to see if it's the Commands class or not. Take out the line in Scintilla's constructor that initializes it. If you get the same behavior you know that it's something else. Another thing to try is creating a form with a standard Tab Control instead of the DockPanel.

Apr 22, 2009 at 5:50 PM
I found the problem and post the fix the below. For some reason, dockPanel lost track of which tab contains the active document when you use ctrl-tab. But somehow dockPanel.ActivePane has the correct information when dockPanel.ActiveDocument doesn't. Sometimes dockPanel.ActivePane is null but dockPanel.ActiveDocument is not so we have to test both before returning.

In MainForm.cs, replace the original property ActiveDocument with the following code:

public DocumentForm ActiveDocument {
    get {
        if (dockPanel.ActivePane != null && dockPanel.ActivePane.ActiveContent != null) {
            return dockPanel.ActivePane.ActiveContent as DocumentForm;
        } else if (dockPanel.ActiveDocument != null) {
            return dockPanel.ActiveDocument as DocumentForm;
        } else {
            return null;
        }
    }
}