mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-21 11:01:36 +00:00
Normalize mouse events received by the modder through EventHandlers
This commit is contained in:
parent
332cd0690b
commit
0953f11a04
1 changed files with 24 additions and 3 deletions
|
@ -471,6 +471,25 @@ bool E_Responder(const event_t* ev)
|
|||
{
|
||||
bool uiProcessorsFound = false;
|
||||
|
||||
// FIRST, check if there are UI processors
|
||||
// if there are, block mouse input
|
||||
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
if (handler->IsUiProcessor)
|
||||
{
|
||||
uiProcessorsFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if this was an input mouse event (occasionally happens) we need to block it without showing it to the modder.
|
||||
bool isUiMouseEvent = (ev->type == EV_GUI_Event && ev->subtype >= EV_GUI_FirstMouseEvent && ev->subtype <= EV_GUI_LastMouseEvent);
|
||||
bool isInputMouseEvent = (ev->type == EV_Mouse) || // input mouse movement
|
||||
((ev->type == EV_KeyDown || ev->type == EV_KeyUp) && ev->data1 >= KEY_MOUSE1 && ev->data1 <= KEY_MOUSE8); // or input mouse click
|
||||
|
||||
if (isInputMouseEvent && uiProcessorsFound)
|
||||
return true; // block event from propagating
|
||||
|
||||
if (ev->type == EV_GUI_Event)
|
||||
{
|
||||
// iterate handlers back to front by order, and give them this event.
|
||||
|
@ -478,7 +497,8 @@ bool E_Responder(const event_t* ev)
|
|||
{
|
||||
if (handler->IsUiProcessor)
|
||||
{
|
||||
uiProcessorsFound = true;
|
||||
if (isUiMouseEvent && !handler->RequireMouse)
|
||||
continue; // don't provide mouse event if not requested
|
||||
if (handler->UiProcess(ev))
|
||||
return true; // event was processed
|
||||
}
|
||||
|
@ -489,14 +509,15 @@ bool E_Responder(const event_t* ev)
|
|||
// not sure if we want to handle device changes, but whatevs.
|
||||
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
// do not process input events for UI
|
||||
if (handler->IsUiProcessor)
|
||||
uiProcessorsFound = true;
|
||||
continue;
|
||||
if (handler->InputProcess(ev))
|
||||
return true; // event was processed
|
||||
}
|
||||
}
|
||||
|
||||
return (uiProcessorsFound && (ev->type == EV_Mouse)); // mouse events are eaten by the event system if there are any uiprocessors.
|
||||
return false;
|
||||
}
|
||||
|
||||
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
||||
|
|
Loading…
Reference in a new issue