Slick Forums

Discuss the Slick 2D Library
It is currently Sun Oct 20, 2019 9:11 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: mouse event routing
PostPosted: Tue Mar 05, 2013 2:10 am 
Offline

Joined: Sun Jul 18, 2010 2:10 pm
Posts: 32
i'm trying to capture mouse click events before children. but I'm having some difficulty. please correct me if I'm wrong:

* to do this, i need to return false for all mouse events (or at least for MOUSE_ENTERED) in direct children, and direct children of children. otherwise that child (direct or indirect) will have mouse focus and mouse events will be routed to it
* -although too verbose- this works, but in this case child widget's custom cursor is not rendered. because getWidgetUnderMouse never points to that child widget.


Top
 Profile  
 
 Post subject: Re: mouse event routing
PostPosted: Tue Mar 05, 2013 6:49 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
There is no way to intercept mouse routing like that. Why do you need that?

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: mouse event routing
PostPosted: Tue Mar 05, 2013 7:12 am 
Offline

Joined: Sun Jul 18, 2010 2:10 pm
Posts: 32
for something like "click to scroll" list. but i guess there can be many other uses.


Top
 Profile  
 
 Post subject: Re: mouse event routing
PostPosted: Tue Mar 05, 2013 9:06 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
Can't you just have the widgets report drag events to the parent - similar to how TextArea and ScrollPane do it?

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: mouse event routing
PostPosted: Tue Mar 05, 2013 10:21 pm 
Offline

Joined: Sun Jul 18, 2010 2:10 pm
Posts: 32
yes, that's also possible I suppose. but it's not nice a widget knows about its ListBox like parent.

maybe putting an invisible "glass pane" covering all the widget area is the way to go, what do you think?


Top
 Profile  
 
 Post subject: Re: mouse event routing
PostPosted: Sun Jul 28, 2013 11:42 am 
Offline

Joined: Sun Jul 28, 2013 10:57 am
Posts: 1
Although this topic is old, I want to add some information here for it helped solving my problem.

I had a similar problem while creating a custom button.
The button should be clickable, but it had child elements which consumed most of the mouse events.

To make the parent button clickable again, I found out two ways to prevent mouse events being caught by child widgets. These I want to share here:
  • The child forwards events to the parent.
    Code:
    public class LabelWidget extends TextWidget {
       [...]
       @Override
       protected boolean handleEvent(Event evt) {
          return ParentButton.this.handleEvent(evt);
    }

    This worked fine for mouse events but it did not work out for tooltips.
  • The child is not target of any mouse events.
    Code:
    public class LabelWidget extends TextWidget {
       [...]
       @Override
       protected boolean isMouseInside(Event evt) {
          return false;
       }
    }


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group