copy-paste bug

28 views
Skip to first unread message

msb

unread,
Jun 13, 2013, 7:09:20 PM6/13/13
to wikidpa...@googlegroups.com
Hi all,

I have a bug that is driving me crazy, and I'm trying to debug it, so I'd like some help here.
The short explanation of the bug is that sometimes I copy text (ctrl-c) from one tab, change tabs (crtl-tab), paste the text (ctrl-v) in another tab, but the text doesn't appear; when I go back to the previous tab, the text is there, i.e., it pasted the text in the inactive/previous tab. The worst part is that it happens sometimes, not all the time. And to make it even more confusing, apparently this problem never happens if I copy-paste using the mouse right-click menu; that actually usually fix things... for a while.
I've added several debug prints to my wikidpad source, and I keep an eye on the log whenever that happens, but I'm still not able to locate the problem. If anyone could tell me how to print the wikiword of the active tab inside Paste() in WikiTxtCtrl.py, that could be helpful. I can already print the wikiword of the tab being pasted to, using:

print "MSB-DEBUG: paste (" + self.presenter.getWikiWord() + "): "+text

But the result is consistent with the behaviour, i.e., it prints the name of tab where the text is actually being pasted. Now, in theory that _should_ be the same as the active tab, but it's not, and I'd like to confirm that by printing the name of the active tab, so that I know if the code gets lost as to which one is the active tab or if it gets lost as to which tab to paste to.
Apparently there's also a bug when copying the text, but that's another topic and I'll address it after fixing this one.

Thanks,
   Mauricio   

Michael Butscher

unread,
Jun 14, 2013, 9:52:32 AM6/14/13
to wikidpa...@googlegroups.com
Retrieving the current presenter is done with:

self.presenter.getMainControl().getMainAreaPanel().getCurrentPresenter()

If it is a DocPagePresenter (usual case) you can use getWikiWord() on it.


Some more technical details:

When hitting Ctrl-V then this is initially handled in PersonalWikiFrame by a
call to _OnRoundTripEvent() with an event having the command id
GUI_ID.CMD_CLIPBOARD_PASTE.

_OnRoundtripEvent is called to send this wxCommandEvent to the window currently
having focus (first try). Command events in wxPython automatically "bubble up"
to the parent window if they were not handled by the window receiving the event.
If the parent window didn't handle it either it goes to the grandparent and so
on until it arrives at PersonalWikiFrame again if no window took care.

In the second try the current DocPagePresenter (if any) gets the event (if it
wasn't the focused window from first try). Once again the event is either
handled or bubbles up until it reaches PersonalWikiFrame again. In this case it
is discarded then.

It may be helpful to log also which window has focus when paste occurs and
compare it to the WikiTxtCtrl on which Paste() was called.

repr(wx.Window.FindFocus()) and repr(self) return a representation of these
windows with a class name and a hexadecimal id.



Michael

msb

unread,
Jun 14, 2013, 5:49:41 PM6/14/13
to wikidpa...@googlegroups.com
Thank you, Michael!
I don't see any _OnRoundTripEvent, is it a new development? I'm using wikidPad 2.2beta10... ok, I know it's a bit far from the latest version. <:-)
I've added a print of repr(wx.Window.FindFocus())  and  repr(self) in the paste part as you suggested, let's see if I can understand the output when it happens again... ^_^

   Mauricio   

msb

unread,
Jun 14, 2013, 6:14:05 PM6/14/13
to wikidpa...@googlegroups.com
Ok, I've found _OnRoundTripEvent... I was looking in the wrong place. heheh
I also got wikidPad 2.3beta09_02 and added my debug prints in it, I'll come back for more help after I gather more information. :-)
Reply all
Reply to author
Forward
0 new messages