You can set an isDown flag when the mouse is pressed.
Then clear the isDown flag when the mouse is released.
And track mouseout + the isDown flag to see if user is leaving with mouse pressed
Here's the jQuery version:
var isDown=false;
$(stage.getContent()).on('mousedown',function(e){ isDown=true; });
$(stage.getContent()).on('mouseup',function(e){ isDown=false; });
$(stage.getContent()).on('mouseout',function(e){
console.log(isDown);
isDown=false;
});
Here's code and a Fiddle: http://jsfiddle.net/m1erickson/ZjKGS/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Prototype</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.0.min.js"></script>
<style>
#container{
border:solid 1px #ccc;
margin-top: 10px;
width:400px;
height:400px;
}
</style>
<script>
$(function(){
var stage = new Kinetic.Stage({
container: 'container',
width: 300,
height: 300
});
var layer = new Kinetic.Layer();
stage.add(layer);
var isDown = false;
$(stage.getContent()).on('mousedown', function (e) {
isDown = true;
});
$(stage.getContent()).on('mouseup', function (e) {
isDown = true;
});
$(stage.getContent()).on('mouseout', function (e) {
if(isDown){
$("#indicator").text("Moved out and mouse was pressed");
}else{
$("#indicator").text("Moved out and mouse was not pressed");
}
isDown = false;
});
layer.draw();
}); // end $(function(){});
</script>
</head>
<body>
<p>Move mouse out of kinetic stage</p>
<p>Indicator will tell if mouse was also pressed</p>
<p id="indicator">Indicator</p>
<div id="container"></div>
</body>
</html>