wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
AenBleidd
Earned a small fee
Earned a small fee
Posts: 10
Joined: Mon Oct 02, 2017 1:51 am
Location: Friedrichshafen, Germany

wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by AenBleidd »

Hello,

I described the problem here: https://stackoverflow.com/q/46511028/4210508
Please help me to solve it.

Thanks
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by doublemax »

The first thing to check is if html->SelectionToText() actually returns the correct text or an empty string. I assume the latter.
Use the source, Luke!
User avatar
AenBleidd
Earned a small fee
Earned a small fee
Posts: 10
Joined: Mon Oct 02, 2017 1:51 am
Location: Friedrichshafen, Germany

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by AenBleidd »

doublemax wrote:The first thing to check is if html->SelectionToText() actually returns the correct text or an empty string. I assume the latter.
html->SelectionToText() always return correct data. And this data is stored in wxTheClipboard. The problem is that this data doesn't appear in the system clipboard. If I cal wxTheClipboard->GetData() I see my data but when I try to paste it in text editor I see either empty string or old data.
So it looks like the issue with wxTheClipboard itself (despite it returns 'true' when I call wxTheClipboard->SetData()).
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by doublemax »

In that case i can only assume that the wxTextDataObject contains a different format in one of the cases, maybe one is wxDF_TEXT and the other is wxDF_UNICODETEXT, but only one of them works. Research further in that direction.
http://docs.wxwidgets.org/trunk/classwx ... 5cfbdb9188
Use the source, Luke!
User avatar
AenBleidd
Earned a small fee
Earned a small fee
Posts: 10
Joined: Mon Oct 02, 2017 1:51 am
Location: Friedrichshafen, Germany

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by AenBleidd »

So it means that
copyTextToClipboard(html->ToText());
and
copyTextToClipboard(html->SelectionToText());
on the same content give different results?
Both these methods return wxString which means they are both Unicode (content of my wxHtmlWindow contains Unicode characters).
So what's wrong with them?
I can provide you the strings that I try to copy to clipboard.

Thanks
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by doublemax »

I only work under Windows, so i can't test this.

The first thing you should check if my theory is correct and the wxTextDataObjects are indeed different in both cases.
Use the source, Luke!
User avatar
AenBleidd
Earned a small fee
Earned a small fee
Posts: 10
Joined: Mon Oct 02, 2017 1:51 am
Location: Friedrichshafen, Germany

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by AenBleidd »

I checked: in both case data type is wxDF_UNICODETEXT.
The text that can be copied:

$7 = L"\nОбщие\nURL\nhttp://einstein.phys.uwm.edu/\nИмя участника\nVitalii Koshura\nКоманда\nВыделено ресурсов\n100\nИспользование диска\n8,45 MB\nИдентификатор компьютера\n11724403\nПриостановлен вручную\nнет\nНе запрашивать задания\nнет\nРазмещение компьютера\nпо умолчанию\nЗавершённых успешно заданий\n0\nЗавершённых неудачно заданий\n0\nОчки\nУчастник\n3.020.308 всего, 1.975,57 в среднем\nКомпьютер (хост)\n57.125 всего, 56,66 в среднем\nПланировщик\nПриоритет планировщика\n-2,12\nПоправочный коэффициент продолжительности\n1,7690\nПоследний ответ планировщика\nСуб 30 Сен 2017 22:32:31\n"

The text that cannot be copied (also it brokes the ability to copy the text above):

$8 = L"\nВыделено ресурсов\n100\nИспользование диска\n8,45 MB\n"
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by doublemax »

Maye this is even unrelated to wxHtmlWindow. If it is and it can be reproduced easily in one of the samples (with small modifications), please open a bug report at: http://trac.wxwidgets.org/
Use the source, Luke!
User avatar
AenBleidd
Earned a small fee
Earned a small fee
Posts: 10
Joined: Mon Oct 02, 2017 1:51 am
Location: Friedrichshafen, Germany

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by AenBleidd »

Sorry for long delay.

Here's the modified Hello World app with the behavior mentioned before:

https://github.com/AenBleidd/wx-issue-test
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by doublemax »

Did you check if wxHtmlWindow really plays a role in this issue? What if you use hardcoded values for the strings you usually get from html->SelectionToText() and html->ToText() ?
Use the source, Luke!
User avatar
AenBleidd
Earned a small fee
Earned a small fee
Posts: 10
Joined: Mon Oct 02, 2017 1:51 am
Location: Friedrichshafen, Germany

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by AenBleidd »

I checked. If I set needed text directly it works until 'm_txtInformation->SelectionToText()' is called.
I do not know what's happening but if I didn't call this all works OK.
Once I call this function nothing works.

What additional information should I provide to get help?

Could you please also report this?
For some reasons I can't create an account there: verification email is not sent.

Thanks
S.K.
Earned a small fee
Earned a small fee
Posts: 11
Joined: Tue Sep 26, 2017 2:50 pm

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by S.K. »

AenBleidd wrote: Could you please also report this?
For some reasons I can't create an account there: verification email is not sent.
I had the same problem with the registration. I used the resend verification mail option a day later, then I received the verification mail.
User avatar
AenBleidd
Earned a small fee
Earned a small fee
Posts: 10
Joined: Mon Oct 02, 2017 1:51 am
Location: Friedrichshafen, Germany

Re: wxHtmlWindow::SelectionToText doesn't copied to clipboard using wxTheClipboard

Post by AenBleidd »

Thank you for your advice.

Ticket is created: https://trac.wxwidgets.org/ticket/18031#ticket
Post Reply