Author: spitzak
Date: 2007-06-15 16:39:57 -0400 (Fri, 15 Jun 2007)
New Revision: 5906
Log:
Made the pushed state available to subclasses in flag(PUSHED). Without
this they could not draw differently when pushed in!


Modified:
   trunk/src/Button.cxx

Modified: trunk/src/Button.cxx
===================================================================
--- trunk/src/Button.cxx        2007-06-13 10:30:25 UTC (rev 5905)
+++ trunk/src/Button.cxx        2007-06-15 20:39:57 UTC (rev 5906)
@@ -71,7 +71,6 @@
   the user clicks it and releases it.
 */
 
-static Button* pushed_button;
 static bool initial_state;
 
 int Button::handle(int event) {
@@ -88,12 +87,19 @@
   case PUSH:
     if (pushed()) return 1; // ignore extra pushes on currently-pushed button
     initial_state = state();
-    pushed_button = 0;
+    clear_flag(PUSHED);
   case DRAG: {
     bool inside = event_inside(rectangle);
-    if (inside != (pushed_button == this)) {
-      pushed_button = inside ? this : 0;
-      redraw(DAMAGE_VALUE); // redraw the pushed state
+    if (inside) {
+      if (!flag(PUSHED)) {
+        set_flag(PUSHED);
+        redraw(DAMAGE_VALUE);
+      }
+    } else {
+      if (flag(PUSHED)) {
+        clear_flag(PUSHED);
+        redraw(DAMAGE_VALUE);
+      }
     }
     if (when() & WHEN_CHANGED) { // momentary button must record state()
       if (state(inside ? !initial_state : initial_state))
@@ -101,7 +107,8 @@
     }
     return 1;}
   case RELEASE:
-    if (pushed_button != this) return 1;
+    if (!flag(PUSHED)) return 1;
+    clear_flag(PUSHED);
     redraw(DAMAGE_VALUE);
     if (type() == RADIO)
       setonly();
@@ -175,8 +182,7 @@
 
   Box* box = style->buttonbox();
 
-  Flags box_flags = flags() & ~PUSHED | OUTPUT;
-  if (this == pushed_button && pushed()) box_flags |= PUSHED;
+  Flags box_flags = flags() | OUTPUT;
   Flags glyph_flags = box_flags & ~(HIGHLIGHT|OUTPUT);
   if (glyph_width) box_flags &= ~STATE;
 

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to