浏览代码

oops, pgEntry bug

David Rose 24 年之前
父节点
当前提交
4f443920f2
共有 4 个文件被更改,包括 32 次插入44 次删除
  1. 1 1
      panda/src/pgui/pgItem.I
  2. 23 42
      panda/src/tform/mouseWatcher.cxx
  3. 0 1
      panda/src/tform/mouseWatcher.h
  4. 8 0
      panda/src/tform/mouseWatcherParameter.cxx

+ 1 - 1
panda/src/pgui/pgItem.I

@@ -439,7 +439,7 @@ get_release_event(const ButtonHandle &button) const {
 ////////////////////////////////////////////////////////////////////
 INLINE string PGItem::
 get_keystroke_event() const {
-  return get_keystroke_prefix() + "-" + get_id();
+  return get_keystroke_prefix() + get_id();
 }
 
 ////////////////////////////////////////////////////////////////////

+ 23 - 42
panda/src/tform/mouseWatcher.cxx

@@ -694,39 +694,19 @@ keystroke(int keycode) {
   param.set_modifier_buttons(_mods);
   param.set_mouse(_mouse);
 
-  // Send the event to every region that wants keyboard buttons,
-  // regardless of the mouse position.
-  if (_preferred_region != (MouseWatcherRegion *)NULL) {
-    // Our current region, the one under the mouse, always get
-    // all the keyboard events, even if it doesn't set its
-    // keyboard flag.
-    _preferred_region->keystroke(param);
-  }
-
-  if ((_suppress_flags & MouseWatcherRegion::SF_other_button) == 0) {
-    // All the other regions only get the keyboard events if they
-    // set their global keyboard flag, *and* the current region does
-    // not suppress keyboard buttons.
-    param.set_outside(true);
-    global_keystroke(param);
-  }
-}
+  // Keystrokes go to all those regions that want keyboard events,
+  // regardless of which is the "preferred" region (that is, without
+  // respect to the mouse position).  However, we do set the outside
+  // flag according to whether the given region is preferred region or
+  // not.
 
-////////////////////////////////////////////////////////////////////
-//     Function: MouseWatcher::global_keyboard_press
-//       Access: Protected
-//  Description: Calls press() on all regions that are interested in
-//               receiving global keyboard events, except for the
-//               current region (which already received this one).
-////////////////////////////////////////////////////////////////////
-void MouseWatcher::
-global_keyboard_press(const MouseWatcherParameter &param) {
   Regions::const_iterator ri;
   for (ri = _regions.begin(); ri != _regions.end(); ++ri) {
     MouseWatcherRegion *region = (*ri);
 
-    if (region != _preferred_region && region->get_keyboard()) {
-      region->press(param);
+    if (region->get_keyboard()) {
+      param.set_outside(region != _preferred_region);
+      region->keystroke(param);
     }
   }
 
@@ -737,27 +717,29 @@ global_keyboard_press(const MouseWatcherParameter &param) {
     for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) {
       MouseWatcherRegion *region = (*ri);
 
-      if (region != _preferred_region && region->get_keyboard()) {
-        region->press(param);
+      if (region->get_keyboard()) {
+        param.set_outside(region != _preferred_region);
+        region->keystroke(param);
       }
     }
   }
 }
+
 ////////////////////////////////////////////////////////////////////
-//     Function: MouseWatcher::global_keyboard_release
+//     Function: MouseWatcher::global_keyboard_press
 //       Access: Protected
-//  Description: Calls release() on all regions that are interested in
+//  Description: Calls press() on all regions that are interested in
 //               receiving global keyboard events, except for the
 //               current region (which already received this one).
 ////////////////////////////////////////////////////////////////////
 void MouseWatcher::
-global_keyboard_release(const MouseWatcherParameter &param) {
+global_keyboard_press(const MouseWatcherParameter &param) {
   Regions::const_iterator ri;
   for (ri = _regions.begin(); ri != _regions.end(); ++ri) {
     MouseWatcherRegion *region = (*ri);
 
     if (region != _preferred_region && region->get_keyboard()) {
-      region->release(param);
+      region->press(param);
     }
   }
 
@@ -769,27 +751,26 @@ global_keyboard_release(const MouseWatcherParameter &param) {
       MouseWatcherRegion *region = (*ri);
 
       if (region != _preferred_region && region->get_keyboard()) {
-        region->release(param);
+        region->press(param);
       }
     }
   }
 }
-
 ////////////////////////////////////////////////////////////////////
-//     Function: MouseWatcher::global_keystroke
+//     Function: MouseWatcher::global_keyboard_release
 //       Access: Protected
-//  Description: Calls keystroke() on all regions that are interested
-//               in receiving global keyboard events, except for the
+//  Description: Calls release() on all regions that are interested in
+//               receiving global keyboard events, except for the
 //               current region (which already received this one).
 ////////////////////////////////////////////////////////////////////
 void MouseWatcher::
-global_keystroke(const MouseWatcherParameter &param) {
+global_keyboard_release(const MouseWatcherParameter &param) {
   Regions::const_iterator ri;
   for (ri = _regions.begin(); ri != _regions.end(); ++ri) {
     MouseWatcherRegion *region = (*ri);
 
     if (region != _preferred_region && region->get_keyboard()) {
-      region->keystroke(param);
+      region->release(param);
     }
   }
 
@@ -801,7 +782,7 @@ global_keystroke(const MouseWatcherParameter &param) {
       MouseWatcherRegion *region = (*ri);
 
       if (region != _preferred_region && region->get_keyboard()) {
-        region->keystroke(param);
+        region->release(param);
       }
     }
   }

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

@@ -138,7 +138,6 @@ protected:
   void keystroke(int keycode);
   void global_keyboard_press(const MouseWatcherParameter &param);
   void global_keyboard_release(const MouseWatcherParameter &param);
-  void global_keystroke(const MouseWatcherParameter &param);
 
   INLINE void within_region(MouseWatcherRegion *region, const MouseWatcherParameter &param);
   INLINE void without_region(MouseWatcherRegion *region, const MouseWatcherParameter &param);

+ 8 - 0
panda/src/tform/mouseWatcherParameter.cxx

@@ -32,6 +32,14 @@ output(ostream &out) const {
     output_anything = true;
   }
 
+  if (has_keycode()) {
+    if (output_anything) {
+      out << ", ";
+    }
+    out << "key" << _keycode;
+    output_anything = true;
+  }
+
   if (_mods.is_any_down()) {
     if (output_anything) {
       out << ", ";