Revision: 1056
Author: allain.lalonde
Date: Fri Aug 27 13:54:17 2010
Log: fixing a bug with text bounds in PText constructor, and making clicking on PCanvas handle the event rather than bubbling it up to other scripts
http://code.google.com/p/piccolo2d/source/detail?r=1056

Modified:
 /piccolo2d.js/trunk/piccolo2d.js

=======================================
--- /piccolo2d.js/trunk/piccolo2d.js    Thu Aug 26 12:57:21 2010
+++ /piccolo2d.js/trunk/piccolo2d.js    Fri Aug 27 13:54:17 2010
@@ -511,12 +511,13 @@
             } else if (arg) {
                 this.text = arg.text;
                 this._super(arg);
+                this.recomputeBounds();
             } else {
                 throw "Invalid argument for PText constructor";
             }
         },

-        paint: function (ctx) {
+        paint: function (ctx) {
if (this.getGlobalFullBounds().height * ctx.displayScale < 3) {
                 return;
             }
@@ -534,6 +535,8 @@
           var metric = PText.hiddenContext.measureText(this.text);
           this.bounds.width = metric.width;
           this.bounds.height = this.text ? PText.fontSize : 0;
+          this.fullBounds = null;
+          this.globalFullBounds = null;
         }
     });
PText.hiddenContext = document.createElement("canvas").getContext("2d");
@@ -744,6 +747,8 @@
             }

             function processMouseEvent(name, event) {
+                event.preventDefault();
+
                 var offset = $(canvas).offset(),
                     x = event.pageX - offset.left,
                     y = event.pageY - offset.top,

--
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to