Thanks for the tip, Doug ... the only problem is that I want the toolbar to be 
a generic component that doesn't require any specially awareness from other 
components in the form. I don't want to mandate that other programmers have to 
modify their event-handling code just to accommodate my toolbar weirdness....  
I'm a little surprised this has turned out to be so challenging. Since I know 
various components provided by Macromedia (such as Button) do behave correctly, 
I guess that there is a 'standardized' way to implement this....



tony pujals| senior engineer | Yahoo! SiteBuilder Express
p. 408.349.6284 | e. tonyp * yahoo-inc . com | y!id tonypujals

________________________________________
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Doug 
Lowder
Sent: Wednesday, February 15, 2006 11:02 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Mouse Event Filtering

Tony, I had a similar problem in Flex 1.5 with a custom TitleWindow 
component that was receiving events from objects underneath it.  
Never did find out exactly why that was happening; non-100% alpha 
value, perhaps?  Anyway, I solved it by wrapping a simple check 
around the event handler that makes sure the target property of the 
event is the current object: 

if (event.target == this) { // handle the event... }

It might be worth trying that somewhere, like in a delegate for the 
mouseMove event or in handleEvent().

Hope that's of some help.

Doug


--- In flexcoders@yahoogroups.com, "Tony Pujals" <[EMAIL PROTECTED]> wrote:
>
> Well, the Flash asdocs really don't make this clear, but I 
initially had a suspicion that overriding a handler instead of 
registering a listener might be the answer. I didn't pursue that 
direction right away because the method signatures don't return a 
Boolean or some other value to indicate that an event was handled 
and no further processing is wanted.
> 
> In any case, I was able to achieve the glass pane effect that I 
wanted this morning with the following code:
> 
> 
>       options = { width: "100%", height: "100%"};
>       Canvas(createChild(Canvas, "_glassPane", options));
>       _glassPane.setStyle("backgroundColor", "#FF00FF");
>       _glassPane.alpha = 0;
>       _glassPane.visible = false;
> 
>       MovieClip(_glassPane).onPress = function() {}
> 
> 
> All of the above was required: without a backgroundColor being 
set, events weren't captured at all; The alpha, of course, was to 
make the glass pane actually invisible (there maybe other properties 
beside backgroundColor that also work for causing events to get 
caught, but I haven't experimented). The visible property -- once a 
backgroundColor property is set -- is what enables and disables the 
event capturing.
> 
> 
> However, for the toolbar that I also wanted to capture events so 
the text component below doesn't receive them, this is not yet a 
complete solution because it also prevents the child components (the 
toolbar buttons) from getting any events either. I've written some 
code to iterate the child components, but I don't know what to pass 
to them -- it seems intrinsically wrong that the toolbar needs to 
become an event manager from its onPress handler:
> 
> // doesn't work -- onPress doesn't have event parameter anyway...
> 
> MovieClip(this).onPress = mx.utils.Delegate.create(this, function
(event) {
>   var comp : UIObject = null;
>   for (var i : Number = 0; i < childDescriptors.length; i++) {
>     comp = getChildAt(i);
>     if (hitTest(comp)) {
>       comp.handleEvent(event);
>     }
>   }
> });
> 
> (Incidentally, if there is some other more appropriate way for 
iterating child components, I'd appreciate hearing about it).
> 
> So Flash/Flex gurus ... what am I missing here...? Thanks!
> 
> Tony
> 
> tony pujals| senior engineer | Yahoo! SiteBuilder Express
> p. 408.349.6284 | e. tonyp * yahoo-inc . com | y!id tonypujals
> 
> ________________________________________
> From: Tony Pujals 
> Sent: Wednesday, February 15, 2006 7:43 AM
> To: 'flexcoders@yahoogroups.com'
> Subject: RE: [flexcoders] Mouse Event Filtering
> 
> Sorry, I don't know if this works in the Flex 2 beta, but I should 
have specified that we're working with Flex 1.5 at Yahoo. 
Unfortunately, EventDispatcher states:
> 
>                 function addEventListener(eventType:String, 
eventListener):Void
>                 {
>                                 // Note: In the future, we may add 
a third parameter,
>                                 // useCapture:Boolean, to be 
compliant with the
>                                 // DOM Level 3 Events spec,
>                                 // http://www.w3.org/TR/DOM-Level-
3-Events/events.html.
>                                 .
>                                 .
>                                 .
> 
> This would have been very convenient if it were implemented. 
Nevertheless, Button and other components do seem able to capture 
the event. Is this a question for one of the Flash lists (any 
recommendation to which list I should post this question)?
> 
> Thanks, Matt - if you or anyone else has any other ideas, I'd 
really love to hear them
> 
> -Tony
> 
> 
> 
> tony pujals| senior engineer | Yahoo! SiteBuilder Express
> p. 408.349.6284 | e. tonyp * yahoo-inc . com | y!id tonypujals
> ________________________________________
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of Matt Chotin
> Sent: Tuesday, February 14, 2006 9:45 PM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Mouse Event Filtering
> 
> you want to add your mouse event listener with useCapture set to 
true
> and then call stopPropagation on the event in your handler (I 
think).  I
> believe that will prevent it from moving further down the 
hierarchy.
> 
> -----Original Message-----
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
> Behalf Of Tony Pujals
> Sent: Tuesday, February 14, 2006 5:27 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Mouse Event Filtering
> 
> There are two variations to my question, but they should share a 
common
> solution:
> 
> 1) I want to create a "glass pane" - ie, a transparent layer that 
can
> capture/consume mouse events without allowing the event to bubble 
to a
> component below it. I've tried to achieve this effect with a 
transparent
> Canvas, but the component below it (eg, a TextArea), also catches 
the
> event.
> 
> 2) I have a floating toolbar that extends Canvas. I don't want to 
use
> the PopUpManager because of issues with the FocusManager and 
TextArea
> that causes text to be selected incorrectly when focus is returned 
after
> focus was transferred to a toolbar button. If the toolbar is 
floating
> above the TextArea component, the cursor changes to an ibeam. If I 
click
> down on the toolbar to drag it, the toolbar drags, but the 
TextArea also
> gets the events, causing text to become selected. I want the 
toolbar to
> consume the mouse events occurring on it without any further event
> bubbling.
> 
> 
> Since the toolbar has a mouseMove handler that allows me to drag 
it, I
> can drag even by pressing mouse down on a toolbar button. I guess 
the
> toolbar as parent is receiving and handling the mousedown, even 
though
> the mouse down event is also propagating to its child button 
component
> as well (I actually do not want this behavior either, but I 
suppose I
> can solve this easily enough with hitTest). But what is really
> interesting is that the event stops there if it's caught by the 
button
> -- the TextArea below the toolbar doesn't get the event in this 
case. So
> something about a Button or its superclasses makes it special, but 
the
> difference isn't apparent to me in the AS source provided with 
Flex.
> 
> Any insight is appreciated. Thanks!
> 
> -Tony
> 
> 
> 
> tony pujals| senior engineer | Yahoo! SiteBuilder Express
> p. 408.349.6284 | e. tonyp * yahoo-inc . com | y!id tonypujals
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com 
> 
> SPONSORED LINKS 
> Web site design development 
> Computer software development 
> Software design and development 
> Macromedia flex 
> Software development best practice 
> 
> 
> ________________________________________
> YAHOO! GROUPS LINKS 
> 
> *  Visit your group "flexcoders" on the web.
>   
> *  To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>   
> *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service. 
> 
> ________________________________________
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 


SPONSORED LINKS 
Web site design development 
Computer software development 
Software design and development 
Macromedia flex 
Software development best practice 


________________________________________
YAHOO! GROUPS LINKS 

*  Visit your group "flexcoders" on the web.
  
*  To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
*  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

________________________________________



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to