Here are the diffs to work around the copy/paste bug in CB main.cpp and allow correct pasting in ThreadSearch.
However, it still will not allow the CB menu, menu hotkeys, or the toolbar icons to be used for copy paste because main.cpp is disabling those in its UpdateUI routine if the focus is
not on an editor.
It will, however, allow Ctrl-C and Ctrl-V to work correctly.
ThreadSearchView.h
c:\Usr\Proj\ThreadSearch\ThreadSearch7>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr ThreadSearchView.h ..
--- ThreadSearchView.h 2007-06-26 10:02:52.000000000 -0500
+++ ../ThreadSearchView.h 2007-06-30 11:27:19.390625000 -0500
@@ -40,6 +40,8 @@
class ThreadSearchThread;
class ThreadSearchView: public MessageLog {
+
+ friend class ThreadSearch;
public:
// begin wxGlade: ThreadSearchView::ids
// end wxGlade
ThreadSearch.H
c:\Usr\Proj\ThreadSearch\ThreadSearch7>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr ThreadSearch.h ..
--- ThreadSearch.h 2007-06-28 20:30:16.000000000 -0500
+++ ../ThreadSearch.h 2007-06-30 11:11:56.515625000 -0500
@@ -233,6 +233,8 @@
* the 'Find implementation' item if possible
*/
int GetInsertionMenuIndex(const wxMenu* const pCtxMenu);
+ void OnEditPaste(wxCommandEvent& event);
+
// Member variables
wxString m_SearchedWord; // Word under cursor on right click
@@ -247,6 +249,8 @@
bool m_ShowDirControls; // True if user wants to display directory specific controls
bool m_DisplayLogHeaders;
bool m_DrawLogLines;
+ bool b_OnReleased;
+ wxComboBox* m_pCboSearchExpr;
DECLARE_EVENT_TABLE();
};
ThreadSearch.cpp
c:\Usr\Proj\ThreadSearch\ThreadSearch7>C:\Usr\bin\GnuWin32\bin\diff.exe -u --strip-trailing-cr ThreadSearch.cpp ..
--- ThreadSearch.cpp 2007-06-28 21:12:28.000000000 -0500
+++ ../ThreadSearch.cpp 2007-06-30 12:13:47.640625000 -0500
@@ -18,6 +18,7 @@
#include <configurationpanel.h>
#include <editor_hooks.h>
#include <wx/wxFlatNotebook/wxFlatNotebook.h>
+#include <wx/clipbrd.h>
#include "ThreadSearch.h"
#include "ThreadSearchConfPanel.h"
@@ -32,6 +33,7 @@
PluginRegistrant<ThreadSearch> reg(_T("ThreadSearch"));
}
+int idEditPaste = XRCID("idEditPaste");
// events handling
BEGIN_EVENT_TABLE(ThreadSearch, cbPlugin)
@@ -44,6 +46,8 @@
EVT_BUTTON (idBtnOptions, ThreadSearch::OnBtnOptionsClick)
EVT_BUTTON (idBtnSearch, ThreadSearch::OnBtnSearchClick)
EVT_TEXT_ENTER(idCboSearchExpr, ThreadSearch::OnCboSearchExprEnter)
+ EVT_TEXT (idCboSearchExpr, ThreadSearch::OnCboSearchExprEnter)
+ EVT_MENU (idEditPaste, ThreadSearch::OnEditPaste)
END_EVENT_TABLE()
// constructor
@@ -57,7 +61,8 @@
m_ShowSearchControls(true),
m_ShowDirControls(false),
m_DisplayLogHeaders(true),
- m_DrawLogLines(false)
+ m_DrawLogLines(false),
+ m_pCboSearchExpr(0)
{
// Make sure our resources are available.
// In the generated boilerplate code we have no resources but when
@@ -99,6 +104,8 @@
// Shows/Hides search widgets on the Messages notebook ThreadSearch panel
m_pThreadSearchView->ShowSearchControls(m_ShowSearchControls);
+
+ b_OnReleased = false;
}
void ThreadSearch::OnRelease(bool appShutDown)
@@ -109,6 +116,12 @@
// NOTE: after this function, the inherited member variable
// m_IsAttached will be FALSE...
+ // --------------------------------------------------------------
+ // Carefull! This routine can be entered consecutive times
+ // --------------------------------------------------------------
+ if ( b_OnReleased ) return;
+ b_OnReleased = true;
+
// Removes Thread search menu item from the View menu
RemoveMenuItems();
@@ -594,7 +606,8 @@
// Runs a multi threaded search with combo text
wxComboBox* pCboBox = static_cast<wxComboBox*>(m_pToolbar->FindControl(idCboSearchExpr));
wxASSERT(pCboBox != NULL);
- RunThreadSearch(pCboBox->GetValue());
+ if ( event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER )
+ RunThreadSearch(pCboBox->GetValue());
}
@@ -648,3 +661,75 @@
return wordFound;
}
+// ----------------------------------------------------------------------------
+void ThreadSearch::OnEditPaste(wxCommandEvent& event)
+// ----------------------------------------------------------------------------
+{
+ // Process clipboard data only if we have the focus
+
+ // ----------------------------------------------------------------
+ // NB: A bug in CB main.cpp causes a ctrl-v to always paste into the
+ // current editor. Here, we'll make checks to see if the paste
+ // is for our search combo boxes and paste the data there.
+ // If the focused window is one of ours that shouldn't get pasted
+ // data, we'll simply ignore it.
+ // If the window isn't one of ours, we'll event.Skip();
+ // ----------------------------------------------------------------
+
+ if ( !IsAttached() )
+ { event.Skip(); return; }
+
+ if (not m_IsAttached) {event.Skip(); return;}
+
+ wxWindow* pFocused = wxWindow::FindFocus();
+ if (not pFocused) { event.Skip(); return; }
+
+ wxString focusedStr = pFocused->GetName();
+ //DBGLOG(wxT("OnEditPaste:Focused[%p][%s]"), pFocused, focusedStr.c_str());
+
+ // don't allow paste when the following windows have the focus
+ if ( ( pFocused == m_pThreadSearchView->m_pSearchPreview )
+ || ( pFocused == m_pThreadSearchView->m_pListLog ) )
+ { return; }
+ if ( pFocused == m_pThreadSearchView->m_pListLog->GetListControl())
+ return;
+
+ // if the following window have the focus, own the paste.
+ if ( (pFocused != m_pCboSearchExpr)
+ && (pFocused != m_pThreadSearchView->m_pCboSearchExpr) )
+ { event.Skip(); return;}
+
+ if ( not wxTheClipboard->Open() )
+ {
+ //DBGLOG( wxT("ThreadSearch::OnPaste Can't open clipboard.") );
+ event.Skip();
+ return;
+ }
+ // -- Text Processing ----------------------------------------------------
+ if ( not wxTheClipboard->IsSupported(wxDF_TEXT) )
+ {
+ //DBGLOG( wxT("ThreadSearch::OnPaste:No text data on clipboard") );
+ wxTheClipboard->Close();
+ event.Skip();
+ return;
+ }
+
+ wxTextDataObject text;
+ if ( not wxTheClipboard->GetData(text) ) {
+ //DBGLOG( wxT("ThreadSearch::OnPaste:Can't get text from the clipboard") );
+ }
+ else { // Put text in search wxComboBoxes
+ wxString str = text.GetText();
+ // stuff the search boxes
+ if (pFocused == m_pCboSearchExpr)
+ m_pCboSearchExpr->SetValue(str);
+ if (pFocused == m_pThreadSearchView->m_pCboSearchExpr)
+ m_pThreadSearchView->m_pCboSearchExpr->SetValue(str);
+ }
+
+ wxTheClipboard->Close();
+ // If you Skip(), CB main.cpp will wrongly paste your text into the current editor
+ // because CB main.cpp thinks it owns the clipboard.
+ //- event.Skip();
+ return; //own the event
+}//OnEditPaste