The canvas gets the click event because of the event bubbling.
 
You can handle the situation in two ways.
 
In canvasClicked you can check the event.target to be the canvas only before taking any action.
 
You can call event.stopPropagation() in the button click handler to prevent the event from bubbling up to the canvas.
 
On 3/6/06, svolix <[EMAIL PROTECTED]> wrote:
One of my custom components extends the Canvas and has a button on it.
Both the canvas and button are rigged to activate seperate functions
when clicked.  I've called them canvasClicked() and buttonClicked().

Now, clicking on the canvas where the button isn't triggers the
canvasClicked() function, as planned.  However, clicking on the
button, which is within the Canvas region, appears to trigger both
canvasClicked() and buttonClicked().

The hack-y way I thought of to make sure that only buttonClicked()
actually does anything is to introduce a semaphore-like mechanism to
both functions (that is, buttonClicked() sets a flag to true; do
canvasClicked() only if flag is false).  But there must be a better
way to handle this.  Anyone know what it is?  Thanks.





--
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/






--
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




Reply via email to