diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index cf317ad584..37003aef79 100644 --- a/panda/src/pgui/pgItem.I +++ b/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(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index a46a5fe6d9..a9050ea530 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -694,21 +694,34 @@ 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); + // 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. + + Regions::const_iterator ri; + for (ri = _regions.begin(); ri != _regions.end(); ++ri) { + MouseWatcherRegion *region = (*ri); + + if (region->get_keyboard()) { + param.set_outside(region != _preferred_region); + 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); + // Also check all of our sub-groups. + Groups::const_iterator gi; + for (gi = _groups.begin(); gi != _groups.end(); ++gi) { + MouseWatcherGroup *group = (*gi); + for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { + MouseWatcherRegion *region = (*ri); + + if (region->get_keyboard()) { + param.set_outside(region != _preferred_region); + region->keystroke(param); + } + } } } @@ -775,38 +788,6 @@ global_keyboard_release(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::global_keystroke -// Access: Protected -// Description: Calls keystroke() 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 ¶m) { - 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); - } - } - - // Also check all of our sub-groups. - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); - - if (region != _preferred_region && region->get_keyboard()) { - region->keystroke(param); - } - } - } -} - //////////////////////////////////////////////////////////////////// // Function: MouseWatcher::enter_region // Access: Protected diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index 0dd3f6aad2..1ad4b84312 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -138,7 +138,6 @@ protected: void keystroke(int keycode); void global_keyboard_press(const MouseWatcherParameter ¶m); void global_keyboard_release(const MouseWatcherParameter ¶m); - void global_keystroke(const MouseWatcherParameter ¶m); INLINE void within_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m); INLINE void without_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m); diff --git a/panda/src/tform/mouseWatcherParameter.cxx b/panda/src/tform/mouseWatcherParameter.cxx index ed442f3aff..49767d16d6 100644 --- a/panda/src/tform/mouseWatcherParameter.cxx +++ b/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 << ", ";