Skip to content

Commit 54c6eae

Browse files
committed
pgui: allow keyboard keys to be added as PGButton click buttons
These will respond as clicks not when the mouse cursor is hovering over them, but when they have keyboard focus. Fixes panda3d#600
1 parent db00baa commit 54c6eae

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

panda/src/pgui/pgButton.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ release(const MouseWatcherParameter &param, bool background) {
115115
if (has_click_button(param.get_button())) {
116116
_button_down = false;
117117
if (get_active()) {
118-
if (param.is_outside()) {
118+
// Note that a "click" may come from a keyboard button press. In that
119+
// case, instead of checking that the mouse cursor is still over the
120+
// button, we check whether the item has keyboard focus.
121+
if (param.is_outside() &&
122+
(MouseButton::is_mouse_button(param.get_button()) || !get_focus())) {
119123
set_state(S_ready);
120124
} else {
121125
set_state(S_rollover);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy