monitor mouse events but not capture them

Martin Sladecek martin.sladecek at oracle.com
Mon Jun 9 08:13:54 UTC 2014


OK, so to avoid further confusion, you have a PopupWindow with a Pane 
and you want to capture Events on the Pane and sent those events to the 
underlying controls (in a parent window) if those events are not 
relevant to that popup?

Thanks,
-Martin

On 06/09/2014 10:07 AM, Tom Eugelink wrote:
>
> Hm, maybe I chose bad words; I'm not using Canvas, but just a Pane. 
> Since the Pane is only used to draw the menu on when it need to 
> appear, I'm calling it the canvas pane, as in "what is painted on".
>
>
> On 2014-6-9 9:46, Martin Sladecek wrote:
>> Just looked at the code and it seems Canvas does pick on bounds 
>> independently of the pickOnBounds value. There's currently no logic 
>> for picking only when over an opaque pixel ( worth filing a JIRA 
>> issue maybe?). This makes Canvas to consume everything as it's always 
>> picked instead of some controls underneath.
>>
>> Unfortunately, I can't think of any solution that would work right 
>> now. If we'd support Node picking 
>> (https://javafx-jira.kenai.com/browse/RT-20184), it would be possible 
>> to "redirect" an unwanted event to a different event target on that 
>> mouse position.
>>
>> -Martin
>>
>>
>> On 06/09/2014 08:44 AM, Tom Eugelink wrote:
>>>
>>> Yessss. It does not work on the canvas pane, I suspect because of 
>>> the pickOnBounds, but it does work on the stackpane. Plus, I can 
>>> register to the stack pane without claiming the onMouseClick/Press 
>>> hook.
>>>
>>> Many thanks!
>>>
>>> Tom
>>>
>>>
>>>
>>> On 2014-6-9 8:29, Martin Sladecek wrote:
>>>> Hi Tom,
>>>> have you tried .addEventFilter() method? It receives the Event 
>>>> before the controls underneath the canvas, in the capturing phase. 
>>>> If you don't consume the Event, it should pass down to the controls.
>>>> For more on the topic, see 
>>>> http://docs.oracle.com/javafx/2/events/processing.htm or 
>>>> http://parleys.com/play/514892290364bc17fc56c39f
>>>>
>>>> -Martin
>>>>
>>>> On 06/09/2014 08:19 AM, Tom Eugelink wrote:
>>>>> Hi all,
>>>>>
>>>>> Maybe someone has solved this already, so I thought I pop the 
>>>>> question. Currently I'm working on CirclePopupMenu; a menu that is 
>>>>> supposed to pop up on any place in a scene when a certain (usually 
>>>>> the middle or right) mouse button is pressed.
>>>>>
>>>>> Right now CirclePopupMenu requires a stackpane to which it binds 
>>>>> itself. CirclePopupMenu initially places an empty "canvas" Pane on 
>>>>> the stack pane, and will use that to render and position the menu 
>>>>> when it needs to appear.
>>>>>
>>>>> Also I need to monitor the mouse to detect if the menu should 
>>>>> appear. In order to do that, I would like to use that canvas pane, 
>>>>> but then any non relevant button clicks will not reach the 
>>>>> underlying controls. In order to enable correct behavior I need to 
>>>>> setPickOnBounds(false) on the pane, but then it does receive the 
>>>>> mouse events anymore.
>>>>>
>>>>> Is there any way to monitor mouse events but still pass them 
>>>>> through to the underlying controls? In Swing I did something 
>>>>> similar and used a system level mouse event hook.
>>>>>
>>>>> Tom
>>>>>
>>>>> PS: I'm not certain if the stackpane approach I've used is the 
>>>>> best way to do this. It does work expect the mouse button problem. 
>>>>> But any suggestions are welcome.
>>>>
>>>
>>>
>>
>
>



More information about the openjfx-dev mailing list