Abhish Mahajan
Abhish Mahajan

Reputation: 7

how to find out click event in canvas,kinetic js

I am trying to find click event on shape. when i click on shape like rectangle its become drag-gable but when i click outside of it,it should off its resizable feature. i tried with blur function but doesn't work. i don't want it on mouse out. problem is when i click on rectangle it gives me alert but when i click on canvas it gives me that alert twice because that shape is part of canvas. so please suggest me how to distinguish between click on shape and out side of shape. how to find out click event in canvas,kinetic js

Upvotes: 0

Views: 462

Answers (1)

RUSHABH SHAH
RUSHABH SHAH

Reputation: 135

you can try something like this

 appendEvents: function(box, area){
        _self = this;

        // add cursor styling
        box.on('mouseover', function() {
            _self.draw = false;
            document.body.style.cursor = 'pointer';
        });
        box.on('mouseout', function() {
            document.body.style.cursor = 'default';
        });
        box.on('click', function() {
            _self.draw = true;
            _self.focusArea(area, box,box.attrs.x,box.attrs.y);
            _self.openFocusArea(area,box,box.attrs.x,box.attrs.y);
        });
        box.on('dragend', function() {
            _self.draw = false;
            _self.dragArea(area, box);
        });
    },

Upvotes: 1

Related Questions