[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] A GUI test for pasting
From: |
Vaclav Slavik |
Subject: |
Re: [lmi] A GUI test for pasting |
Date: |
Mon, 4 Feb 2008 19:50:46 +0100 |
User-agent: |
KMail/1.9.7 |
Greg Chicares wrote:
> I added that line (using ::SendMessage() for pasting), but it
> still doesn't work for me: now only the initial '1' pastes,
> but that's because UponPaste() returns even earlier and the
> event is skipped. I think I'd better wait and see what you
> come up with.
This patch against HEAD makes the test work (the important
part is using wxDataObjectComposite):
Index: main_wx.cpp
===================================================================
RCS file: /sources/lmi/lmi/main_wx.cpp,v
retrieving revision 1.92
diff -u -u -r1.92 main_wx.cpp
--- main_wx.cpp 2 Feb 2008 20:22:32 -0000 1.92
+++ main_wx.cpp 4 Feb 2008 18:48:07 -0000
@@ -941,17 +941,26 @@
void Skeleton::UponTestPasting(wxCommandEvent&)
{
// Put sample data onto the clipboard.
- wxString s("Excel\0[Book1]Sheet1\0R1C2:R7C2\0\0");
+ {
+ wxClipboardLocker locker;
+ wxString s("Excel\0[Book1]Sheet1\0R1C1:R3C1\0\0");
wxDataFormat df("Link");
wxCustomDataObject* x = new wxCustomDataObject(df);
x->SetData(s.length(), s.c_str());
- wxTheClipboard->AddData(x);
+
+ char const* p = "\r\n1\r\r\n2\r\r\n3\r\r\n\r\n\0\0\0\0";
+ wxTextDataObject *t = new wxTextDataObject(p);
+
+ wxDataObjectComposite *comp = new wxDataObjectComposite();
+ comp->Add(x);
+ comp->Add(t);
+ wxTheClipboard->AddData(comp);
+ }
// Generate an event to pretend that text was pasted.
wxTextCtrl* t = new wxTextCtrl(frame_, wxID_ANY, "xyzzy");
- wxClipboardTextEvent e(wxEVT_COMMAND_TEXT_PASTE, t->GetId());
- e.SetEventObject(t);
- wxPostEvent(t, e);
+ HWND handle = reinterpret_cast<HWND>(t->GetHandle());
+ ::SendMessage(handle, WM_PASTE, 0, 0);
wxYield();
warning()
--
PGP key: 0x465264C9, available from http://pgp.mit.edu/