Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't Detect Mouseover on This KineticJS Shape?
    primarykey
    data
    text
    <p>I have a KineticJS shape that draws a bezier curve that is wider on one end. It draws correctly, but I can't yet detect a 'mouseover' event on it. I have created a small JSFiddle demo of the anomaly, at:</p> <p><a href="http://jsfiddle.net/VikR0001/nZYxL/6/" rel="nofollow">http://jsfiddle.net/VikR0001/nZYxL/6/</a></p> <p>How can I detect 'mouseover' events on this shape?</p> <p>Thanks very much in advance to all for any info!</p> <pre><code> var mainLayer; //bezier curve code: //http://stackoverflow.com/questions/8325680/how-to-draw-a-bezier-curve-with-variable-thickness-on-an-html-canvas //draw a bezier curve that gets larger as it flows //adapted for use with KineticJS function drawBezierCurve() { var centerLeft = new Object(); centerLeft.x = 100; centerLeft.y = 400; var centerRight = new Object(); centerRight.x = 400; centerRight.y = 100; var thicknessLeft = 1; var thicknessRight = 50; var color = "#000"; var context = mainLayer.getContext(); var leftUpper = { x: centerLeft.x, y: centerLeft.y - thicknessLeft / 2 }; var leftLower = { x: centerLeft.x, y: leftUpper.y + thicknessLeft }; var rightUpper = { x: centerRight.x, y: centerRight.y - thicknessRight / 2 }; var rightLower = { x: centerRight.x, y: rightUpper.y + thicknessRight }; var center = (centerRight.x + centerLeft.x) / 2; var cp1Upper = { x: center, y: leftUpper.y }; var cp2Upper = { x: center, y: rightUpper.y }; var cp1Lower = { x: center, y: rightLower.y }; var cp2Lower = { x: center, y: leftLower.y }; var bezierCurve = new Kinetic.Shape({ drawFunc: function (canvas) { var context = mainLayer.getContext(); context.fillStyle = color; context.beginPath(); context.moveTo(leftUpper.x, leftUpper.y); context.bezierCurveTo(cp1Upper.x, cp1Upper.y, cp2Upper.x, cp2Upper.y, rightUpper.x, rightUpper.y); context.lineTo(rightLower.x, rightLower.y); context.bezierCurveTo(cp1Lower.x, cp1Lower.y, cp2Lower.x, cp2Lower.y, leftLower.x, leftLower.y); context.lineTo(leftUpper.x, leftUpper.y); context.fill(); canvas.stroke(this); }, fill: color, stroke: color, strokeWidth: 1 }); bezierCurve.on('mouseover', function (evt) { document.body.style.cursor = "pointer"; $("#debug").html("MOUSEOVER DETECTED."); //&lt;==NEVER CALLED }); bezierCurve.on('mouseout', function (evt) { document.body.style.cursor = "default"; $("#debug").html("MOUSEOUT DETECTED."); //NEVER CALLED }); bezierCurve.setAttrs({ 'leftUpper': leftUpper, 'leftLower': leftLower, 'rightUpper': rightUpper, 'rightLower': rightLower, 'cp1Upper': cp1Upper, 'cp2Upper': cp2Upper, 'cp1Lower': cp1Lower, 'cp2Lower': cp2Lower }); mainLayer.add(bezierCurve); mainLayer.draw(); $("#debug").html("bezier curve has been drawn onscreen."); } $(document).ready(function () { var stage = new Kinetic.Stage({ container: 'canvasContainer', width: 500, height: 500 }); mainLayer = new Kinetic.Layer('main'); stage.add(mainLayer); mainLayer.draw(); drawBezierCurve(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload