12 Sep 2012 7:40 AM #1
Unanswered: Problem with mouse events and custom composite sprites
I'm working on an advanced drawing component, which extends "Ext.draw.Component" and shows different groups of sprites on a map. The surface holds several groups of composite sprites in its "groups" collection. Each group in this case is a custom class as well (extending "Ext.draw.CompositeSprite"), while each group contains a list of custom sprites (extending "Ext.draw.Sprite").
Everything works fine, except for my desired mouse events. I'm trying to attach "click" and "mousemove" event handlers to each created sprite, but they are never called, because the corresponding events don't seem to fire.
If I leave out my custom groups and add the sprites directly to the items collection of the component's surface, these problems disappear. But I definitely need my groups, inespecially to make it easier to execute common operations on groups of sprites (as described in the api docs) and to prevent the surface from adding composite sprites automatically to the surface, if they don't exist already (standard behaviour).
It seems that the events aren't dispatched correctly when using composite sprites?
Can everybody confirm this behaviour or give me a hint how to solve this?
I'm using ExtJS 4.1.0
Thanks in advance!
13 Sep 2012 10:59 PM #2
I found a dirty workaround to achieve my desired behaviour. I forward the component's mousedown event to my sprites. In the corresponding sprite event handler I filter by the event's target to determine, if the mousedown event was really "over" my sprite or over the underlying drawing surface. If it was, I stop the event, so it's not further dispatched to other components:
/* "sprite" is my custom Ext.draw.Sprite instance "this" is my custom Ext.draw.Component instance - in the api docs it's written that surface events are forwarded to the drawing component by default, so I can use "this" instead of "this.surface" */ sprite.relayEvents(this, ['mousedown']);
19 Oct 2012 7:19 AM #3
Did you ever find a better solution to this? I think I'm seeing the same problem.
I have an app that works with 4.0.2a, but with 4.1.1a the Sprite events are no longer delivered. Did you ever find a better solution? I seems like something is broken.