PDA

View Full Version : Ext.EventObject.stopEvent() doesn't work on Chrome



Daniels
6 Nov 2009, 2:47 AM
Hi guys.

I'm work on a prototype, where I need use the mousemove event. I'm using Ext.EventObject.stopEvent() and it works really fine on Internet Explorer and Firefox, but on Chrome the default mousemove action of the browser doesn't stop.

What I need to do for stop mousemove event of Chrome and just run my mousemove event?

Condor
6 Nov 2009, 3:35 AM
Can you give an example?

Here the message is never shown:

<div id="one"><div id="two">Mouse over me!</div></div>
<script type="text/javascript">
Ext.onReady(function() {
Ext.get('one').on('mouseover', function(e){
console.log('Don\'t show me!');
});
Ext.get('two').on('mouseover', function(e){
e.stopEvent();
});
});
</script>

Daniels
6 Nov 2009, 4:04 AM
The code works like this:



evtFunction: function(table) {
table.on('mouseover', myFunction, this);
},
//some code here..
myFunction: function() {
Ext.EventObject.stopEvent();
//more code...
}
The picture shows the result on Firerox(left) and Chrome(right) running the same code. As you can see, the mousemove event continues on Chrome and does what I don't want.

I forgot one detail: I use mousemove for select cells of a table. I'm set a flag true on mousedown and set false when mouseup. So this occurs when mouse button is pressed and moved, like a drag.

Condor
6 Nov 2009, 4:10 AM
No, that will only work in Internet Explorer (because there the event is a singleton).

On all other browsers you need to stop the actual event:

myFunction: function(evt){
evt.stopEvent();
//more code...
}

Daniels
6 Nov 2009, 4:21 AM
It doesn't work:


evtFunction: function(table) {
table.on('mousemove', myFunction, this);
},
//some code here..
myFunction: function(evt) {
evt.stopEvent();
//more code...
}The IE and Firefox still running ok, but Chrome don't want to help me, and shows the browser event =(

Condor
6 Nov 2009, 4:40 AM
Is this really about the mousemove event or about the fact that you can select text?

To make text unselectable you need to add class="x-unselectable" to your table.

Daniels
6 Nov 2009, 4:52 AM
It works. I just don't know why the IE works without this, but anyway, now the code works correctly =)

Thanks for your help, Condor.