From 719ee9c389634c6e51908b8a298884df520c196b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 10 Jun 2004 00:09:27 +0000 Subject: [PATCH] Take care of some focus issues with the AutoComp list box and also a crash at exit when losing focus. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/PlatWX.cpp | 24 +++++++++++++++++++++++- contrib/src/stc/stc.cpp | 5 ++++- contrib/src/stc/stc.cpp.in | 5 ++++- src/stc/PlatWX.cpp | 24 +++++++++++++++++++++++- src/stc/stc.cpp | 5 ++++- src/stc/stc.cpp.in | 5 ++++- 6 files changed, 62 insertions(+), 6 deletions(-) diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index ab3e95c9d5..43b6a2a443 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -684,6 +684,7 @@ public: : wxListView(parent, id, pos, size, style) {} + void OnFocus(wxFocusEvent& event) { GetParent()->SetFocus(); event.Skip(); @@ -692,7 +693,24 @@ public: void OnKillFocus(wxFocusEvent& WXUNUSED(event)) { // Do nothing. Prevents base class from resetting the colors... } + +#ifdef __WXMAC__ + // For some reason I don't understand yet the focus doesn't really leave + // the listbox like it should, so if we get any events feed them back to + // the wxSTC + void OnKeyDown(wxKeyEvent& event) { + GetGrandParent()->GetEventHandler()->ProcessEvent(event); + } + void OnChar(wxKeyEvent& event) { + GetGrandParent()->GetEventHandler()->ProcessEvent(event); + } + // And we need to force the focus back when being destroyed + ~wxSTCListBox() { + GetGrandParent()->SetFocus(); + } +#endif + private: DECLARE_EVENT_TABLE() }; @@ -700,6 +718,10 @@ private: BEGIN_EVENT_TABLE(wxSTCListBox, wxListView) EVT_SET_FOCUS( wxSTCListBox::OnFocus) EVT_KILL_FOCUS(wxSTCListBox::OnKillFocus) +#ifdef __WXMAC__ + EVT_KEY_DOWN( wxSTCListBox::OnKeyDown) + EVT_CHAR( wxSTCListBox::OnChar) +#endif END_EVENT_TABLE() @@ -736,7 +758,7 @@ public: // immediately. bool Destroy() { #ifdef __WXMAC__ - // There bottom edge of this window is not getting properly + // The bottom edge of this window is not getting properly // refreshed upon deletion, so help it out... wxWindow* p = GetParent(); wxRect r(GetPosition(), GetSize()); diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index f96e8ffadc..83a9e24895 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -2720,7 +2720,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { - m_swx->DoLoseFocus(); +#ifdef __WXMAC__ + if (! (IsBeingDeleted() || GetParent()->IsBeingDeleted())) +#endif + m_swx->DoLoseFocus(); evt.Skip(); } diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index 11f590c9a4..a52798705e 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -529,7 +529,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { - m_swx->DoLoseFocus(); +#ifdef __WXMAC__ + if (! (IsBeingDeleted() || GetParent()->IsBeingDeleted())) +#endif + m_swx->DoLoseFocus(); evt.Skip(); } diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index ab3e95c9d5..43b6a2a443 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -684,6 +684,7 @@ public: : wxListView(parent, id, pos, size, style) {} + void OnFocus(wxFocusEvent& event) { GetParent()->SetFocus(); event.Skip(); @@ -692,7 +693,24 @@ public: void OnKillFocus(wxFocusEvent& WXUNUSED(event)) { // Do nothing. Prevents base class from resetting the colors... } + +#ifdef __WXMAC__ + // For some reason I don't understand yet the focus doesn't really leave + // the listbox like it should, so if we get any events feed them back to + // the wxSTC + void OnKeyDown(wxKeyEvent& event) { + GetGrandParent()->GetEventHandler()->ProcessEvent(event); + } + void OnChar(wxKeyEvent& event) { + GetGrandParent()->GetEventHandler()->ProcessEvent(event); + } + // And we need to force the focus back when being destroyed + ~wxSTCListBox() { + GetGrandParent()->SetFocus(); + } +#endif + private: DECLARE_EVENT_TABLE() }; @@ -700,6 +718,10 @@ private: BEGIN_EVENT_TABLE(wxSTCListBox, wxListView) EVT_SET_FOCUS( wxSTCListBox::OnFocus) EVT_KILL_FOCUS(wxSTCListBox::OnKillFocus) +#ifdef __WXMAC__ + EVT_KEY_DOWN( wxSTCListBox::OnKeyDown) + EVT_CHAR( wxSTCListBox::OnChar) +#endif END_EVENT_TABLE() @@ -736,7 +758,7 @@ public: // immediately. bool Destroy() { #ifdef __WXMAC__ - // There bottom edge of this window is not getting properly + // The bottom edge of this window is not getting properly // refreshed upon deletion, so help it out... wxWindow* p = GetParent(); wxRect r(GetPosition(), GetSize()); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index f96e8ffadc..83a9e24895 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -2720,7 +2720,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { - m_swx->DoLoseFocus(); +#ifdef __WXMAC__ + if (! (IsBeingDeleted() || GetParent()->IsBeingDeleted())) +#endif + m_swx->DoLoseFocus(); evt.Skip(); } diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 11f590c9a4..a52798705e 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -529,7 +529,10 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { - m_swx->DoLoseFocus(); +#ifdef __WXMAC__ + if (! (IsBeingDeleted() || GetParent()->IsBeingDeleted())) +#endif + m_swx->DoLoseFocus(); evt.Skip(); } -- 2.45.2