--- a/src/widget/widget_button.cpp Sun Mar 04 13:13:24 2007 +0000
+++ b/src/widget/widget_button.cpp Sun Mar 04 22:36:22 2007 +0000
@@ -16,6 +16,7 @@
#include "../genworld.h"
#include "../helpers.hpp"
#include "window_events.hpp"
+#include "widget_types.h"
namespace gui {
@@ -59,16 +60,25 @@
DrawFrameRect(m_color, m_pushed ? FR_LOWERED : FR_NONE);
}
-/*virtual*/ void Button::OnLeftButtonDown(EvtLeftButtonDown &ev)
+/*virtual*/ void Button::OnLeftButtonDown(EvtLeftButtonDown &e)
{
- /* start capturing mouse move events */
- m_ticket_pressed = CaptureEventsT(this, &Button::OnCapturePressed);
+ if ((m_feature_flags & FF_TOGGLE_BUTTON) != FF_NONE) {
+ /* toggle button */
+ m_pushed = !m_pushed;
- /* push the button */
- m_pushed = true;
+ /* issue click event */
+ EvtLeftClick ev(e.m_pt);
+ ev.m_widget = this;
+ OnLeftClick(ev);
+ } else {
+ /* push button */
+ m_pushed = true;
+
+ /* start capturing mouse move events */
+ m_ticket_pressed = CaptureEventsT(this, &Button::OnCapturePressed);
+ }
Invalidate();
-
- ev.SetHandled();
+ e.SetHandled();
}