]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/mousemanager.cpp
Fix another off-by-1 bug in wxMBConv::ToWChar().
[wxWidgets.git] / src / common / mousemanager.cpp
index b05922e3f77bef3e30da94cf2bad4d0a539efb17..20849a0167ae489cf12a8488105f723e079242e7 100644 (file)
@@ -45,18 +45,27 @@ END_EVENT_TABLE()
 // wxMouseEventsManager implementation
 // ============================================================================
 
-wxMouseEventsManager::wxMouseEventsManager(wxWindow *win)
-    : m_win(win)
+void wxMouseEventsManager::Init()
 {
+    m_win = NULL;
     m_state = State_Normal;
     m_item = wxNOT_FOUND;
+}
+
+bool wxMouseEventsManager::Create(wxWindow *win)
+{
+    wxASSERT_MSG( !m_win, "Create() must not be called twice" );
 
+    m_win = win;
     win->PushEventHandler(this);
+
+    return true;
 }
 
 wxMouseEventsManager::~wxMouseEventsManager()
 {
-    m_win->RemoveEventHandler(this);
+    if ( m_win )
+        m_win->RemoveEventHandler(this);
 }
 
 void wxMouseEventsManager::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
@@ -94,6 +103,7 @@ void wxMouseEventsManager::OnLeftDown(wxMouseEvent& event)
     }
 
     m_state = State_Pressed;
+    m_win->SetFocus();
     m_win->CaptureMouse();
     MouseClickBegin(m_item);
 }