Mouse Event Consumption

Discussion of features and help with problems encountered while using libRocket

Mouse Event Consumption

Postby brianheylin on Tue Nov 04, 2014 1:07 pm

Hey all

I'm currently hooking libRocket up to the input system of an in house engine, but I'm running into some difficulty with event consumption.
More specifically, I want to know if a given event is consumed by libRocket or not.

The input system has been connected using just the mouse atm using the following functions

    ProcessMouseMoved
    ProcessMouseButtonDown
    ProcessMouseButtonUp

None of these return a bool to signify consumption, a post on the Panda3D forums (https://www.panda3d.org/forums/viewtopic.php?t=13072) recommended comparing the hover and root element

Code: Select all
bool eventConsumed = a_Context.GetHoverElement() != a_Context.GetRootElement()


This proposition does not work as event propagation always stops at the <body> tag
The code could be modified to compare the hover element to all body tags, but this seems a little messy.

Another post here on libRocket forums recommends using a listener on the root (http://forums.librocket.com/viewtopic.php?f=2&t=159)

Code: Select all

class EventFunctor : public Rocket::Core::EventListener
{
public:
   EventFunctor()
   {   
   }

   virtual void ProcessEvent(Rocket::Core::Event& a_Event)
   {
      Rocket::Core::Element& elem = *a_Event.GetTargetElement();
      LOG_DEBUG(Format("ROOT CALLBACK {0}") % ElementString(elem));
   }
};

m_ConsumedCallback = new EventFunctor(m_ClickEventConsumed);
m_Context->GetRootElement()->AddEventListener("click", m_ConsumedCallback, false);


My first question is: how are people determining if a mouse event processed by librocket is consumed or not?
My second question is: how can I exclude certain <divs> from consuming mouse events?

Imagine I have a div with an image, but I would like the click to fall through to the game world.
Can I set an element as non-interactive?

Thanks for your time
brianheylin
 
Posts: 1
Joined: Tue Nov 04, 2014 12:26 pm

Return to Using libRocket