Author: jmorliaguet
Date: Mon Jan  2 16:18:43 2006
New Revision: 2117

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- fixed the event handling mess.



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Mon Jan  2 
16:18:43 2006
@@ -282,35 +282,42 @@
     var controller = view.getAttribute("controller");
     this.handlers = controllers[controller].handlers;
 
-    this.clickEvent = this.clickEvent.bindAsEventListener(this);
-    Event.observe(document, "click", this.clickEvent);
+    this.showEvent = this.showEvent.bindAsEventListener(this);
+    this.hideEvent = this.hideEvent.bindAsEventListener(this);
+    this.callEvent = this.callEvent.bindAsEventListener(this);
+    Event.observe(this.widget, "mousedown", function(e) {Event.stop(e)});
+    Event.observe(this.widget, "mouseup", this.callEvent);
+    Event.observe(this.area, "mouseup", this.showEvent);
+    Event.observe(document, "mousedown", this.hideEvent);
   },
 
-  clickEvent: function(e) {
+  showEvent: function(e) {
     var element = Event.element(e);
     var x = Event.pointerX(e);
     var y = Event.pointerY(e);
 
     var widget = this.widget;
 
-    if (document.getElementsByClassName("contextMenu", element)) {
-      this.call(element);
+    if (!this.active) {
+      this.selected = Identifiable.getIdentifiable(element);
+      this.show(x, y);
+      this.active = true;
     } else {
-      Element.hide(widget);
-    };
+      this.active = false;
+    }
+  },
 
-    if (Position.within(this.area, x, y)) {
-      if (this.active) {
-        Element.hide(widget)
-      } else {
-        this.selected = Identifiable.getIdentifiable(element);
-        this.show(x, y);
-      }
+  hideEvent: function(e) {
+    Element.hide(this.widget);
+    var x = Event.pointerX(e);
+    var y = Event.pointerY(e);
+    if (!Position.within(this.area, x, y)) {
+      this.active = false;
     }
-    this.active = !this.active;
   },
 
-  call: function(element) {
+  callEvent: function(e) {
+    var element = Event.element(e);
     if (element.getAttribute("disabled")) return;
     var action = element.getAttribute("action");
     if (!action) return;
@@ -323,6 +330,7 @@
     if (handler) {
       handler(this.selected, choice);
       Element.hide(this.widget);
+      this.active = false;
     }
   },
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to