MouseEnter for a Component and its children! SOURCE CODE

Discuss any 3rd-party tools and code that may be of interest to other Juce users

Re: MouseEnter for a Component and its children! SOURCE CODE

Postby acn » Sat Mar 03, 2012 9:30 am

register children's mouseListener inside parent's listener means i should forward my mouseEvent from child to parent, right ? Yeah i tried that, but that involves lot of child things to bring in parent. I tried above thing but in the case i am explaining it's not working.

I simply need that, when
A component's mouseExit is called when exactly mouse goes out of that component not when it goes on button inside it, So problem here is it get mouseExit even if mouse goes over the button inside that component itself.
And that button is exactly in bottom right corner of that component, So that makes mouseExit invisible of component's exit.

Thanks X-Ryl669 for your help and listening to me ;-)
User avatar
acn
JUCE Obsessive
 
Posts: 92
Joined: Thu Sep 15, 2011 8:16 am
Location: India

Re: MouseEnter for a Component and its children! SOURCE CODE

Postby X-Ryl669 » Mon Mar 05, 2012 9:39 am

acn wrote:register children's mouseListener inside parent's listener means i should forward my mouseEvent from child to parent, right ?

No.
Every mouse event (in fact, every pointer event) goes through a filtering system. The system asks this:
1) Is the current component concerned in the event (usually through the hitTest() method) ?
2) Does it want it (by looking if any mouse listener is registered for this component) ?

Currently, the component registers themselves as mouse's Listener, so you don't see this. This doesn't mean you can't register any other component's Listener and this is what I'm talking about here.
The code should read:
Code: Select all
parent::parent()
{
     child1 = new WhateverComponent();
     addAndMakeVisible(child1);

     // Add the child mouse listener to our parent:
    addMouseListener(child1, true);
}

What happens from now, is that in parent class you'll receive event for the parent class BUT also those of the child1. AND the child1 will still receive its events too.
X-Ryl669
X-Ryl669
JUCE UberWeenie
 
Posts: 1125
Joined: Sun Apr 24, 2005 5:30 pm

Re: MouseEnter for a Component and its children! SOURCE CODE

Postby TheVinn » Thu Apr 12, 2012 2:58 am

All of the concepts and code I wrote about regarding treating a Component and its children as a single entity for the purposes of detecting mouse enter and mouse exit, are now in the class MouseEnterGroup in VFLib:

https://github.com/vinniefalco/VFLib
Open Source: LayerEffects, VFLib, SimpleDJ, DSP Filters, LuaBridge, JUCE, FreeType, TagLib
"This isn't a big project, it shouldn't take long." - Jules
User avatar
TheVinn
JUCE UberWeenie
 
Posts: 2989
Joined: Sat Aug 29, 2009 11:31 am
Location: Marina del Rey, California

Previous

Return to Useful Tools and Components

Who is online

Users browsing this forum: embedded_guy and 2 guests