Fixup clipboard usage a bit more.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16790 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2002-08-26 17:50:44 +00:00
parent a8fae7f78d
commit 45c6a92768
2 changed files with 36 additions and 24 deletions

View File

@ -321,11 +321,12 @@ void ScintillaWX::Copy() {
if (currentPos != anchor) {
SelectionText st;
CopySelectionRange(&st);
wxTheClipboard->Open();
wxTheClipboard->UsePrimarySelection();
wxString text = stc2wx(st.s, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close();
if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection();
wxString text = stc2wx(st.s, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close();
}
}
}
@ -335,12 +336,13 @@ void ScintillaWX::Paste() {
ClearSelection();
wxTextDataObject data;
bool gotData;
bool gotData = FALSE;
wxTheClipboard->Open();
wxTheClipboard->UsePrimarySelection();
gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection();
gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
}
if (gotData) {
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText());
int len = strlen(buf);
@ -356,12 +358,16 @@ void ScintillaWX::Paste() {
bool ScintillaWX::CanPaste() {
bool canPaste = FALSE;
bool didOpen;
if (! wxTheClipboard->IsOpened()) {
if ( (didOpen = !wxTheClipboard->IsOpened()) )
wxTheClipboard->Open();
if (wxTheClipboard->IsOpened()) {
wxTheClipboard->UsePrimarySelection();
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
wxTheClipboard->Close();
if (didOpen)
wxTheClipboard->Close();
}
return canPaste;
}

View File

@ -321,11 +321,12 @@ void ScintillaWX::Copy() {
if (currentPos != anchor) {
SelectionText st;
CopySelectionRange(&st);
wxTheClipboard->Open();
wxTheClipboard->UsePrimarySelection();
wxString text = stc2wx(st.s, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close();
if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection();
wxString text = stc2wx(st.s, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close();
}
}
}
@ -335,12 +336,13 @@ void ScintillaWX::Paste() {
ClearSelection();
wxTextDataObject data;
bool gotData;
bool gotData = FALSE;
wxTheClipboard->Open();
wxTheClipboard->UsePrimarySelection();
gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection();
gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
}
if (gotData) {
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText());
int len = strlen(buf);
@ -356,12 +358,16 @@ void ScintillaWX::Paste() {
bool ScintillaWX::CanPaste() {
bool canPaste = FALSE;
bool didOpen;
if (! wxTheClipboard->IsOpened()) {
if ( (didOpen = !wxTheClipboard->IsOpened()) )
wxTheClipboard->Open();
if (wxTheClipboard->IsOpened()) {
wxTheClipboard->UsePrimarySelection();
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
wxTheClipboard->Close();
if (didOpen)
wxTheClipboard->Close();
}
return canPaste;
}