Windows Mobile Copy/Paste problems - maybe Pleco bug?

ldolse

状元
I just had an interesting discovery with copying and pasting Chinese characters from arbitrary applications in Windows Mobile. The accepted behaviour is that you can't copy/paste into Pleco from other applications (outside of Notes and a couple others), but actually you can, but only under these specific conditions:

Exit completely from Pleco using the File-Exit menu.
Copy the Chinese text From any other application.
Start Pleco, Paste the text.
The text will actually paste into Pleco!

Unfortunately it will only do it once. You can only successfully paste characters from any arbitrary app on the very first paste - once a single paste has been made into Pleco something gets screwed up and you're back to the status quo.

This leads me to suspect there's probably some issue with the way 1.0 is handling the buffers vs. an OS issue, as copy paste works everywhere else. This close to 2.0 I'm not looking for a 1.0 patch, I'm just really hoping for better text handling in 2.0.
 

mikelove

皇帝
Staff member
The weird thing about all of this is that we literally do *nothing* to the clipboard before pasting text in; the entire "paste" command is essentially just two lines of code:

HWND focus = GetFocus();
SendMessage(focus, WM_PASTE, 0, 0);

And that's it - the actual paste command is executed by Microsoft's built-in text editor control and we don't have any more say in the matter. You can find these same two lines of code in dozens of different Pocket PC programs... On Palm OS we do a bunch of text encoding conversion stuff before/after you copy and paste, but on Pocket PC all we do is tell the input field that the user wants the clipboard pasted into it.

So it's not like there's some long, bug-filled text pasting routine in here; it's more a matter of figuring out why the paste command isn't doing what it's supposed to do and what Microsoft's own specification says it does. Are you making sure that the cursor is actually blinking in the text edit field before you paste?
 

ldolse

状元
So bizarre

That is very weird, but it actually makes a bit of sense. So I added a little application called Vito CopyPaste to my phone. This actually partially fixes the text dialog problem that Pleco has, as it adds a cut/copy/paste dialog to all text boxes throughout the system. So Pleco's edit menu isn't context sensitive - paste is always there even if there is nothing in the buffer. The Vito application is context sensitive though - paste only shows up as an option when it sees data in the buffer. So if I use the Vito application it shows me that there is nothing at all in the paste buffer - there simply isn't any 'paste' command under scenarios where I can't paste into Pleco. i.e. on first load, first paste as described earlier, Vito shows a Paste option, on subsequent pastes there simply is no paste option for Pleco.

Yet if I copy the exact same piece of chinese text that didn't show up in the paste buffer for Pleco I can easily paste that into some other application. The Vito tool does show that it's in the paste buffer when used in the same way.

It gets a bit stranger too - when I attempt to paste into Pleco it seems like the paste buffer gets cleared for all applications - I could have pasted that text elsewhere if I don't make an attempt to use Pleco, but once I've attempted to use Pleco the data is gone. It looks like the whole paste buffer is cleared by the very act of making a paste attempt into the pleco dialog.

Is it possible Pleco is tripping over itself with the highlighting feature somehow? Maybe it clears the buffer as part of the text reading feature??

Regarding the cursor - yes, it's sitting in the text dialog for all these scenarios.
 

mikelove

皇帝
Staff member
Actually I just figured this out - it must have something to do with Instant Access; that's the other time when Pleco manipulates the clipboard, and it does so by sending out an automatic "Copy" command so that whatever's currently selected gets copied to the clipboard and can then be automatically pasted into the Input Field. (as we haven't yet found another way to even semi-reliably copy highlighted text out of another program)

The eventual fix would be to save out the clipboard's contents before issuing that Copy command, so if it turns out to be nothing useful the old clipboard can be restored, but a workaround in the meantime would simply be to make sure that the text you want to bring up in PlecoDict is highlighted (in addition to being copied to the clipboard) when you launch / switch to it; doing that should prevent Instant Access from overwriting the clipboard.

We're actually seriously considering dropping Instant Access support altogether in 2.0, both on Palm and PPC, in favor of allowing users to easily dump text from the clipboard to a document reader screen; getting Instant Access working on Palm has gotten borderline impossible in 2.0, and on PPC it's never been a very satisfactory feature anyway. It won't be implemented in the beta verison, at least, and we likely won't bring it back unless a lot of people write us to complain about its absence.
 

gato

状元
We're actually seriously considering dropping Instant Access support altogether in 2.0, both on Palm and PPC, in favor of allowing users to easily dump text from the clipboard to a document reader screen;
Does the new built-in document reader have bookmarks, and is it able to save your place in a document if you exit? If not, I probably will still use a third-party reader like TealDoc, in which case the Instant Access feature will be pretty essential.
 

ldolse

状元
I don't think that workaround will do the trick. The Instant Access feature only works with a handful of applications. It looks to me the more I've delved into it that it only works with text editor type apps, all the applications I have where the text can be edited seem to support Instant Access. If the application's text can't be edited then the instant Access feature fails. Unfortunately all the Chinese text I'm ever interested in using the instant access feature for is non-editable - text messages, rss articles, web pages - all of these applications fail to work with instant access.

That brings me to the root of why I don't think the workaround will cut it - I've just highlighted the text in one of those applications and copied it. Pleco is tied to a hardware button - while the text is still highlighted I click the hardware button. Pleco comes to the fore, and then text buffer is now clear. So I think I've just done what you're saying is a workaround, but this still clears the buffer.

The Instant Access thing is a great concept, but if it can't be made to work with non-editable text I'd have to agree that dropping it might make more sense.

As a replacement of the Instant Access feature, Instead manipulating the clipboard on bringing up Pleco, could you just dump 'whatever' is in the clipboard straight into the Pleco text box? This would save a couple steps as now I only need to copy from the one application, I don't need to explicitly go and paste into Pleco.

I think maybe the way to look at the doc reader option is to look at how many bytes are in the clipboard - average chinese character is two bytes, right? So say if there are more than eight bytes in the clipboard bring the doc reader up and dump the text there. The thought being that if it's more than four characters it's something the doc reader makes more sense for, but up to four characters could be one or two words, or a Chengyu that the user can easily work with right in the normal text box.

Most of the time I'm just copying a word to get it into Pleco quickly as a flashcard or look up individual character meanings. If I'm working with SMS I usually just copy a whole sentence into the Pleco text box anyway - it gets a little upset when there are twenty or so characters in the text box, but it works well enough. It's easier to search across dictionaries that way to find different word breaks. I'm not sure how the new text reader is going to work - I think for sure it will supersede the need for dumping text into the notes app, but I'm not sure if it will provide the same flexibility as having a whole sentence in the text box.
 

mikelove

皇帝
Staff member
gato - yes on saving your place in a document, "maybe" on bookmarks - we haven't added them yet, but if we do end up dropping Instant Access support we almost certainly will add them then. Honestly on Palm our main reasons for dropping Instant Access support are technical; it's gotten harder and harder to cram the basic PlecoDict engine code into the 64k of space that Palm OS allows popup applications to occupy, and it's increasingly looking like the time we'd spend working on that seems like it might be better spent elsewhere.

ldolse - we'd been thinking of doing something along those lines regarding copy-and-paste; pretty much all text on a Pocket PC is in Unicode, actually, so all characters (English and Chinese) are double-byte and any length string could conceivably be Chinese, but certainly having an option to check the clipboard on startup and paste its contents to the Input Field (if <= 4 characters long) or open them up in a document reader window would make sense.
 

gato

状元
I see. It's a PalmOS problem.

If you don't have enough time to implement bookmarks, see if you can at least allow "saving places" for multiple documents; in other words, all (or perhaps the last x number of) documents opened instead of just the last one.

And hopefully there's a decent browser for files. :)
 

mikelove

皇帝
Staff member
Well yes, if we can't get bookmarks done we ought to at least let you avoid 10 minutes of scrolling every time you open a document :D

Still no file browser as yet, we're actually trying to automate that somewhat - have it search for and display a list of all flashcard / document / whatever files on the card instead of requiring you to snoop around through the directory structure yourself. Less confusing for non-technical people and a lot closer to the UI on Pocket PC.
 

daniu

榜眼
mikelove said:
We're actually seriously considering dropping Instant Access support altogether in 2.0, both on Palm and PPC, in favor of allowing users to easily dump text from the clipboard to a document reader screen; getting Instant Access working on Palm has gotten borderline impossible in 2.0, and on PPC it's never been a very satisfactory feature anyway. It won't be implemented in the beta verison, at least, and we likely won't bring it back unless a lot of people write us to complain about its absence.

Just found out about the instant access feature. I do not need it at all especially as it does not work with Magic Button (a free taskmanager) and on my PDA PlecoDict usually is on and called through magic button.

Maybe that is much more complicated but how about implementing something on context menu in the os itsself (like: lookup in Plecodict)?

Trying to detect if the clipboard is supposed to be looked up in Pleco by trying to find out if it is chinese text is not the whole story because sometimes ppl might wanna lookup english words as well ...

regards
Daniel
 

mikelove

皇帝
Staff member
Adding something to the OS context menu would be very tricky, I think - there doesn't appear to be an official API for it, which means we'd necessarily treading into hacker territory to get it to work.

And this sort of thing in general is why we hate supporting Instant Access as a feature; there are too many Magic Buttons out there, too many SMS programs / text editors / web browsers / etc, testing for and coding workarounds for all of them to get something like Instant Access working reliably is an exercise in frustration to say the least; even on Palm it still doesn't work that reliably, in spite of having gone through a couple of years of revisions (it originally came out with our old Oxford Dict 2.0 software) and on an OS with far fewer ways for an outside program to manipulate Chinese text.
 

martin78

Member
Hey guys,

I cannot believe it. A couple of days ago I bought a legal copy of this fantastic program and am happily studying my flashcards and looking up words and tell everybody that that is the software I was looking for, BUT when I get a Chinese SMS there is no other way than using my old Lingvosoft Dict to check words because with Pleco I cannot copy from a SMS to the application (having PPC/WM5)...

I tried several of the hints in the forum (exit Pleco, mark, restart...), but none works. Can't you guys just copy the way LIngvosoft does it? To me copy/paste is an essential feature - because "we out here" sometimes just need that.

If anybody could give me any hints how to solve this problem pls let me know asap...
 

mikelove

皇帝
Staff member
So you're both copying the text to the clipboard and making sure it's still highlighted before you launch PlecoDict? In that case, I'm afraid the only advice I can give you is to wait for 2.0 - the beta version due out next week will be rather buggy but does handle pasting text in a sensible way at least, and since it should be able to be installed at the same time as 1.0, even if you can't use it as your everyday dictionary it would at least provide you an alternative to Lingvosoft for looking up text in SMSes.
 

ldolse

状元
You have to use the notes application with SMS, etc. Pleco basically only supports the Instant Access feature from text editors like notepad.

Here's the steps to get this to work:

1. Set up Pleco to a hardware Key (I use PIE)
2. Enable the instant access feature in prefs (I don't think this is required, as it seems to work either way)
3. Copy from your SMS to a note in the Notes application
4. Highlight the text you want to translate in notes, then click the hardware button.

The bug mentioned in this thread is what prevents normal copy/paste from working throughout the rest of windows mobile, so you always need to use the Notes app as a bridge.

Note that the instant access feature works from anywhere in windows mobile where text can be edited (vs just displayed), it doesn't have to be notes. One benefit of this is that when you reply to the SMS and type chinese you can easily doublecheck what you've typed in Pleco - I do this frequently when I'm not sure of the characters - typing them in an IME is a lot easier than copy paste, and I learn the characters more effectively as well. This is one thing I'm really going to miss with 2.0, but I can live with that if copy/paste works normally.
 

martin78

Member
Thanks guys, the "copy to note first"-workaround actually works :D

Still a little complicated... If you can solve this problem, I think you guys are close to the very perfect tool for every person learning Chinese...
 
Top