Hi!
I've just committed a fix to SVN (rev 4027). This fixed a repeatedly
detected behavior that a click event isn't fired in some cases. After
some investigation, the reason for this bug was found. This problem only
exists in Firefox (and other gecko derivatives).
The reason: When the DOM target of the mousedown is different from the
DOM target of the mouseup event there will not be a click event. This
sounds logical. But what, if the content of some button, for example,
moves around, while pressing the it down (for a visual effect). Then the
content will be moved, not the cursor. The problem is that in a specific
coordinate range this makes problems, because then the target is
unexpected different. For example, in the mousedown the target is the
icon of the button, while in the mouseup it's the button itself.
All other browsers seems not to have a problem with this. In Opera even
the targets are identical both times, in IE not.
I've fixed this with some code which compares the targets with the
widget equivalent and fires an additional click event in the misbehaving
cases.
Cheers,
Sebastian
--- Begin Message ---
Revision: 4027
Author: wpbasti
Date: 2006-08-28 04:00:14 -0700 (Mon, 28 Aug 2006)
ViewCVS: http://svn.sourceforge.net/qooxdoo/?rev=4027&view=rev
Log Message:
-----------
Fixed click event in gecko if target changes between mousedown/mouseup without
any cursor movement, minor cleanup of other code (use of qx.Class)
Modified Paths:
--------------
trunk/qooxdoo/frontend/framework/source/class/qx/event/handler/EventHandler.js
Modified:
trunk/qooxdoo/frontend/framework/source/class/qx/event/handler/EventHandler.js
===================================================================
---
trunk/qooxdoo/frontend/framework/source/class/qx/event/handler/EventHandler.js
2006-08-28 09:32:49 UTC (rev 4026)
+++
trunk/qooxdoo/frontend/framework/source/class/qx/event/handler/EventHandler.js
2006-08-28 11:00:14 UTC (rev 4027)
@@ -286,7 +286,7 @@
// If your Mozilla was built with an option `--enable-default-toolkit=gtk2',
// it can not return the correct event target for DOMMouseScroll.
-qx.event.handler.EventHandler.getOriginalTargetObject = function(vNode)
+qx.Class.getOriginalTargetObject = function(vNode)
{
// Events on the HTML element, when using absolute locations which
// are outside the HTML element. Opera does not seem to fire events
@@ -310,7 +310,7 @@
return vNode ? vNode.qx_Widget : null;
}
-qx.event.handler.EventHandler.getOriginalTargetObjectFromEvent =
function(vDomEvent, vWindow)
+qx.Class.getOriginalTargetObjectFromEvent = function(vDomEvent, vWindow)
{
var vNode = vDomEvent.target || vDomEvent.srcElement;
@@ -328,7 +328,7 @@
return qx.event.handler.EventHandler.getOriginalTargetObject(vNode);
}
-qx.event.handler.EventHandler.getRelatedOriginalTargetObjectFromEvent =
function(vDomEvent) {
+qx.Class.getRelatedOriginalTargetObjectFromEvent = function(vDomEvent) {
return
qx.event.handler.EventHandler.getOriginalTargetObject(vDomEvent.relatedTarget
|| (vDomEvent.type == qx.constant.Event.MOUSEOVER ? vDomEvent.fromElement :
vDomEvent.toElement));
}
@@ -338,7 +338,7 @@
-qx.event.handler.EventHandler.getTargetObject = function(vNode, vObject)
+qx.Class.getTargetObject = function(vNode, vObject)
{
if (!vObject)
{
@@ -371,23 +371,23 @@
return vObject;
}
-qx.event.handler.EventHandler.getTargetObjectFromEvent = function(vDomEvent) {
+qx.Class.getTargetObjectFromEvent = function(vDomEvent) {
return qx.event.handler.EventHandler.getTargetObject(vDomEvent.target ||
vDomEvent.srcElement);
}
-qx.event.handler.EventHandler.getRelatedTargetObjectFromEvent =
function(vDomEvent) {
+qx.Class.getRelatedTargetObjectFromEvent = function(vDomEvent) {
return qx.event.handler.EventHandler.getTargetObject(vDomEvent.relatedTarget
|| (vDomEvent.type == qx.constant.Event.MOUSEOVER ? vDomEvent.fromElement :
vDomEvent.toElement));
}
if (qx.sys.Client.getInstance().isMshtml())
{
- qx.event.handler.EventHandler.stopDomEvent = function(vDomEvent) {
+ qx.Class.stopDomEvent = function(vDomEvent) {
vDomEvent.returnValue = false;
}
}
else
{
- qx.event.handler.EventHandler.stopDomEvent = function(vDomEvent)
+ qx.Class.stopDomEvent = function(vDomEvent)
{
vDomEvent.preventDefault();
vDomEvent.returnValue = false;
@@ -634,9 +634,50 @@
}
}
+/*!
+Fixes browser quirks with 'click' detection
+Firefox 1.5.0.6: The DOM-targets are different. The click event only fires, if
the target of the
+ mousedown is the same than with the mouseup. If the content moved away, the
click isn't fired.
+Internet Explorer 6.0: The DOM-targets are identical and the click fires fine.
+Opera 9.01: The DOM-targets are different, but the click fires fine. Fires
click successfull,
+ even if the content under the cursor was moved away.
+*/
+if (qx.sys.Client.getInstance().isGecko())
+{
+ qx.Proto._onmouseevent_click_fix = function(vDomTarget, vType,
vDispatchTarget)
+ {
+ var vReturn = false;
+
+ switch(vType)
+ {
+ case qx.constant.Event.MOUSEDOWN:
+ this._lastMouseDownDomTarget = vDomTarget;
+ this._lastMouseDownDispatchTarget = vDispatchTarget;
+ break;
+
+ case qx.constant.Event.MOUSEUP:
+ // Add additional click event if the dispatch target is the same, but
the dom target is different
+ if (this._lastMouseDownDispatchTarget === vDispatchTarget &&
vDomTarget !== this._lastMouseDownDomTarget) {
+ vReturn = true;
+ }
+
+ this._lastMouseDownDomTarget = null;
+ this._lastMouseDownDispatchTarget = null;
+ }
+
+ return vReturn;
+ };
+}
+else
+{
+ qx.Proto._onmouseevent_click_fix = function(vDomTarget, vDispatchTarget) {
+ return false;
+ }
+};
+
/*!
This is the crossbrowser post handler for all mouse events.
*/
@@ -644,7 +685,7 @@
{
try
{
- var vEventObject, vDispatchTarget, vTarget, vOriginalTarget,
vRelatedTarget;
+ var vEventObject, vCaptureTarget, vDispatchTarget, vTarget,
vOriginalTarget, vRelatedTarget, vFixClick;
@@ -653,26 +694,30 @@
// Check for capturing, if enabled the target is the captured widget.
- vDispatchTarget = this.getCaptureWidget();
+ vCaptureTarget = this.getCaptureWidget();
// Event Target Object
vOriginalTarget =
qx.event.handler.EventHandler.getOriginalTargetObject(vDomTarget);
- // If no capturing is active search for a valid target object
- if (!qx.util.Validation.isValidObject(vDispatchTarget))
+ // If capturing isn't active search for a valid target object
+ if (!vCaptureTarget)
{
// Get Target Object
vDispatchTarget = vTarget =
qx.event.handler.EventHandler.getTargetObject(null, vOriginalTarget);
}
else
{
+ vDispatchTarget = vCaptureTarget;
vTarget = qx.event.handler.EventHandler.getTargetObject(null,
vOriginalTarget);
}
+ // If there is no target, we have nothing TODO
if (!vTarget) {
return false;
}
+ // Fix click event
+ vFixClick = this._onmouseevent_click_fix(vDomTarget, vType,
vDispatchTarget);
@@ -815,6 +860,12 @@
// Flush Queues
qx.ui.core.Widget.flushGlobalQueues();
+
+
+ // Fix Click (Gecko Bug, see above)
+ if (vFixClick) {
+ this._onmouseevent_post(vDomEvent, qx.constant.Event.CLICK, vDomTarget);
+ }
}
catch(ex)
{
@@ -1017,6 +1068,9 @@
this._lastMouseEventDate = null;
this._lastKeyEventType = null;
+ this._lastMouseDownDomTarget = null;
+ this._lastMouseDownDispatchTarget = null;
+
if (this._commands)
{
for (var vHash in this._commands)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
qooxdoo-commit mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-commit
--- End Message ---
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel