diff -r 2ae707873e23 -r c5b92f2d924f src/widget/widget_button.cpp --- a/src/widget/widget_button.cpp Sat Mar 03 11:50:45 2007 +0000 +++ b/src/widget/widget_button.cpp Sat Mar 03 16:11:18 2007 +0000 @@ -21,16 +21,37 @@ void Button::OnCapturePressed(EvtMouseOver &e) { + BaseWindow *w = GetWindow(); + assert(w != NULL); + if (_left_button_down) { + /* translate the global coordinates to our window space */ + Point16 pt_local = e.m_pt - w->TopLeft(); + /* determine the new button push state (is cursor inside button?) */ + bool pushed = (WidgetFromPt(pt_local) != NULL); + /* did the push state change */ + if (pushed != m_pushed) { + /* update button push state */ + m_pushed = pushed; + Invalidate(); + } e.SetHandled(); return; } - m_pushed = false; + /* stop capturing mouse move events */ m_ticket_pressed.Release(); - EvtClick ev(Point(0, 0)); - ev.m_widget = this; - CallHandlers(ev); + /* Issue OnLeftClick() event only if the button was pushed */ + if (m_pushed) { + /* release button */ + m_pushed = false; + Invalidate(); + + /* issue click event */ + EvtLeftClick ev(e.m_pt - w->TopLeft()); + ev.m_widget = this; + OnLeftClick(ev); + } } /*virtual*/ void Button::DrawBackground(EvtPaint &ev) @@ -38,13 +59,18 @@ DrawFrameRect(m_color, m_pushed ? FR_LOWERED : FR_NONE); } -/*virtual*/ void Button::OnLeftClick(EvtClick &ev) +/*virtual*/ void Button::OnLeftButtonDown(EvtLeftButtonDown &ev) { + /* start capturing mouse move events */ + m_ticket_pressed = CaptureEventsT(this, &Button::OnCapturePressed); + + /* push the button */ m_pushed = true; + Invalidate(); + ev.SetHandled(); - m_ticket_pressed = CaptureEventsT(this, &Button::OnCapturePressed); - Invalidate(); } + }; // namespace gui