Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
d01dec2965
2 changed files with 21 additions and 21 deletions
  1. 19 20
      panda/src/tform/mouseWatcher.cxx
  2. 2 1
      panda/src/tform/mouseWatcher.h

+ 19 - 20
panda/src/tform/mouseWatcher.cxx

@@ -32,7 +32,7 @@ MouseWatcher::
 MouseWatcher(const string &name) : DataNode(name) {
 MouseWatcher(const string &name) : DataNode(name) {
   _has_mouse = false;
   _has_mouse = false;
   _current_region = (MouseWatcherRegion *)NULL;
   _current_region = (MouseWatcherRegion *)NULL;
-  _button_down_region = (MouseWatcherRegion *)NULL;
+  _button_down = false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -80,9 +80,6 @@ remove_region(MouseWatcherRegion *region) {
   if (region == _current_region) {
   if (region == _current_region) {
     _current_region = (MouseWatcherRegion *)NULL;
     _current_region = (MouseWatcherRegion *)NULL;
   }
   }
-  if (region == _button_down_region) {
-    _button_down_region = (MouseWatcherRegion *)NULL;
-  }
   return _regions.erase(region) != 0;
   return _regions.erase(region) != 0;
 }
 }
 
 
@@ -249,7 +246,11 @@ transmit_data(NodeAttributes &data) {
 
 
   _has_mouse = true;
   _has_mouse = true;
 
 
-  set_current_region(get_over_region(_mouse));
+  if (!_button_down) {
+    // We don't change regions while we are holding down a
+    // button--only when all buttons are up.
+    set_current_region(get_over_region(_mouse));
+  }
 
 
   // Look for button events.
   // Look for button events.
   const ButtonEventDataAttribute *b;
   const ButtonEventDataAttribute *b;
@@ -264,19 +265,25 @@ transmit_data(NodeAttributes &data) {
 
 
 	// There is some danger of losing button-up events here.  If
 	// There is some danger of losing button-up events here.  If
 	// more than one button goes down together, we won't detect
 	// more than one button goes down together, we won't detect
-	// both the of the button-up events properly.
+	// both of the button-up events properly.
 
 
-	if (_button_down_region != (MouseWatcherRegion *)NULL) {
-	  throw_event_pattern(_button_up_pattern, _button_down_region,
+	if (_current_region != (MouseWatcherRegion *)NULL) {
+	  throw_event_pattern(_button_up_pattern, _current_region,
 			      be._button.get_name());
 			      be._button.get_name());
 	}
 	}
-	_button_down_region = (MouseWatcherRegion *)NULL;
+	_button_down = false;
 	
 	
       } else {
       } else {
 	// Button down.
 	// Button down.
-	_button_down_region = _current_region;
+
+	if (_button_down) {
+	  // Clicking down a second button while still holding the
+	  // first button down does cause a change in regions.
+	  set_current_region(get_over_region(_mouse));
+	}
+	_button_down = true;
 	if (_current_region != (MouseWatcherRegion *)NULL) {
 	if (_current_region != (MouseWatcherRegion *)NULL) {
-	  throw_event_pattern(_button_down_pattern, _button_down_region,
+	  throw_event_pattern(_button_down_pattern, _current_region,
 			      be._button.get_name());
 			      be._button.get_name());
 	}
 	}
       }
       }
@@ -284,15 +291,7 @@ transmit_data(NodeAttributes &data) {
   }
   }
 
 
   bool suppress_below = false;
   bool suppress_below = false;
-
-  if (_button_down_region != (MouseWatcherRegion *)NULL) {
-    // We're currently holding down a button.  This is the effective
-    // region that determines whether we suppress below.
-    suppress_below = _button_down_region->get_suppress_below();
-
-  } else if (_current_region != (MouseWatcherRegion *)NULL) {
-    // We're not holding down a button, but we are within a region.
-    // Use this region to determine whether we suppress below.
+  if (_current_region != (MouseWatcherRegion *)NULL) {
     suppress_below = _current_region->get_suppress_below();
     suppress_below = _current_region->get_suppress_below();
   }
   }
 
 

+ 2 - 1
panda/src/tform/mouseWatcher.h

@@ -93,7 +93,8 @@ private:
   LPoint2f _mouse;
   LPoint2f _mouse;
 
 
   MouseWatcherRegion *_current_region;
   MouseWatcherRegion *_current_region;
-  MouseWatcherRegion *_button_down_region;
+  bool _button_down;
+
   string _button_down_pattern;
   string _button_down_pattern;
   string _button_up_pattern;
   string _button_up_pattern;
   string _enter_pattern;
   string _enter_pattern;