Detecting when user clicks outside of document

Discussion of features and help with problems encountered while using libRocket

Detecting when user clicks outside of document

Postby Aaron on Wed May 29, 2013 2:13 am

When sending mouse events to Rocket, how do I tell when I haven't clicked in a Rocket document?

I'd have a game map with UI panels on top; the panels being documents. I'd have some logic for clicking on the game map itself, but for that I'd need to detect whether or not the mouse event was handled by any documents.

The only thing I can think of is to check the return values of the context's GetHoverElement and GetFocusElement methods, which I'd assume are NULL if there's no hover or focused element, though I'm not sure if those apply to document backgrounds.
Aaron
 
Posts: 1
Joined: Wed May 29, 2013 2:04 am

Re: Detecting when user clicks outside of document

Postby plaristote on Fri Jul 12, 2013 6:47 pm

Oh, oh, I know that ! I did such a thing in my project !

Code: Select all
bool IsHoveringUi(Rocket::Core::Context* context)
{
  return (context->GetHoverElement() != context->GetRootElement());
}


I believe this should work nicely.
plaristote
 
Posts: 18
Joined: Sat May 19, 2012 12:59 am


Return to Using libRocket


cron