@@ -77,11 +77,6 @@ wxCodeCompletionBox::wxCodeCompletionBox(wxWindow* parent, wxEvtHandler* eventOb
7777 m_canvas->Bind (wxEVT_LEFT_DOWN, &wxCodeCompletionBox::OnLeftDClick, this );
7878 m_canvas->Bind (wxEVT_LEFT_DCLICK, &wxCodeCompletionBox::OnLeftDClick, this );
7979
80- EventNotifier::Get ()->Bind (wxEVT_ALL_EDITORS_CLOSING, &wxCodeCompletionBox::OnDismissBox, this );
81- EventNotifier::Get ()->Bind (wxEVT_ACTIVE_EDITOR_CHANGED, &wxCodeCompletionBox::OnDismissBox, this );
82- EventNotifier::Get ()->Bind (wxEVT_EDITOR_CLOSING, &wxCodeCompletionBox::OnDismissBox, this );
83- wxTheApp->Bind (wxEVT_ACTIVATE_APP, &wxCodeCompletionBox::OnAppActivate, this );
84-
8580 // / Set the colours
8681 m_lightBorder = wxColour (" rgb(77, 77, 77)" );
8782 m_darkBorder = wxColour (" rgb(54, 54, 54)" );
@@ -100,22 +95,7 @@ wxCodeCompletionBox::~wxCodeCompletionBox()
10095{
10196 m_canvas->Unbind (wxEVT_LEFT_DOWN, &wxCodeCompletionBox::OnLeftDClick, this );
10297 m_canvas->Unbind (wxEVT_LEFT_DCLICK, &wxCodeCompletionBox::OnLeftDClick, this );
103- if (m_stc) {
104- m_stc->Unbind (wxEVT_KEY_DOWN, &wxCodeCompletionBox::StcKeyDown, this );
105- m_stc->Unbind (wxEVT_LEFT_DOWN, &wxCodeCompletionBox::StcLeftDown, this );
106- }
107-
108- if (m_tipWindow) {
109- m_tipWindow->Hide ();
110- m_tipWindow->Destroy ();
111- m_tipWindow = NULL ;
112- m_displayedTip.Clear ();
113- }
114-
115- wxTheApp->Unbind (wxEVT_ACTIVATE_APP, &wxCodeCompletionBox::OnAppActivate, this );
116- EventNotifier::Get ()->Unbind (wxEVT_ACTIVE_EDITOR_CHANGED, &wxCodeCompletionBox::OnDismissBox, this );
117- EventNotifier::Get ()->Unbind (wxEVT_EDITOR_CLOSING, &wxCodeCompletionBox::OnDismissBox, this );
118- EventNotifier::Get ()->Unbind (wxEVT_ALL_EDITORS_CLOSING, &wxCodeCompletionBox::OnDismissBox, this );
98+ DoDestroyTipWindow ();
11999}
120100
121101void wxCodeCompletionBox::OnEraseBackground (wxEraseEvent& event) { wxUnusedVar (event); }
@@ -265,9 +245,6 @@ void wxCodeCompletionBox::ShowCompletionBox(wxStyledTextCtrl* ctrl, const wxCode
265245 Show ();
266246
267247 if (m_stc) {
268- m_stc->Bind (wxEVT_KEY_DOWN, &wxCodeCompletionBox::StcKeyDown, this );
269- m_stc->Bind (wxEVT_LEFT_DOWN, &wxCodeCompletionBox::StcLeftDown, this );
270-
271248 // Set the focus back to the completion control
272249 m_stc->CallAfter (&wxStyledTextCtrl::SetFocus);
273250 }
@@ -289,12 +266,7 @@ void wxCodeCompletionBox::DoDisplayTipWindow()
289266
290267 if (!docComment.IsEmpty () && docComment != m_displayedTip) {
291268 // destroy old tip window
292- if (m_tipWindow) {
293- m_displayedTip.Clear ();
294- m_tipWindow->Hide ();
295- m_tipWindow->Destroy ();
296- m_tipWindow = NULL ;
297- }
269+ DoDestroyTipWindow ();
298270
299271 // keep the old tip
300272 m_displayedTip = docComment;
@@ -307,12 +279,9 @@ void wxCodeCompletionBox::DoDisplayTipWindow()
307279 m_stc->CallAfter (&wxStyledTextCtrl::SetFocus);
308280 }
309281
310- } else if (m_tipWindow) {
282+ } else {
311283 // Nothing to display, just destroy the old tooltip
312- m_displayedTip.Clear ();
313- m_tipWindow->Hide ();
314- m_tipWindow->Destroy ();
315- m_tipWindow = NULL ;
284+ DoDestroyTipWindow ();
316285 }
317286}
318287
@@ -379,6 +348,9 @@ void wxCodeCompletionBox::StcKeyDown(wxKeyEvent& event)
379348 case WXK_END:
380349 case WXK_DELETE:
381350 case WXK_NUMPAD_DELETE:
351+ case WXK_ALT:
352+ case WXK_WINDOWS_LEFT:
353+ case WXK_WINDOWS_RIGHT:
382354 DoDestroy ();
383355 break ;
384356 case WXK_TAB:
@@ -567,19 +539,6 @@ void wxCodeCompletionBox::DoUpdateList()
567539 }
568540}
569541
570- void wxCodeCompletionBox::OnAppActivate (wxActivateEvent& event)
571- {
572- event.Skip ();
573- // Application lost / got focus - reset the tooltip
574- DoDestroy ();
575- }
576-
577- void wxCodeCompletionBox::OnDismissBox (wxCommandEvent& event)
578- {
579- event.Skip ();
580- DoDestroy ();
581- }
582-
583542wxCodeCompletionBoxEntry::Ptr_t wxCodeCompletionBox::TagToEntry (TagEntryPtr tag)
584543{
585544 wxString text = tag->GetDisplayName ().Trim ().Trim (false );
@@ -606,10 +565,7 @@ void wxCodeCompletionBox::DoScrollUp()
606565 }
607566}
608567
609- void wxCodeCompletionBox::DoDestroy ()
610- {
611- wxCodeCompletionBoxManager::Get ().DestroyCCBox ();
612- }
568+ void wxCodeCompletionBox::DoDestroy () { wxCodeCompletionBoxManager::Get ().DestroyCCBox (); }
613569
614570void wxCodeCompletionBox::DoDrawBottomScrollButton (wxDC& dc)
615571{
@@ -665,3 +621,13 @@ void wxCodeCompletionBox::DoDrawTopScrollButton(wxDC& dc)
665621bool wxCodeCompletionBox::CanScrollDown () { return ((m_index + 1 ) < (int )m_entries.size ()); }
666622
667623bool wxCodeCompletionBox::CanScrollUp () { return ((m_index - 1 ) >= 0 ); }
624+
625+ void wxCodeCompletionBox::DoDestroyTipWindow ()
626+ {
627+ if (m_tipWindow) {
628+ m_tipWindow->Hide ();
629+ m_tipWindow->Destroy ();
630+ m_tipWindow = NULL ;
631+ m_displayedTip.Clear ();
632+ }
633+ }
0 commit comments