2014-09-27 4 views
1

누군가 "click"이벤트와 "contentClick"이벤트의 차이점을 설명 할 수 있습니까?KineticJS에서 "click"이벤트와 "contentClick"이벤트의 차이점은 무엇입니까?

stage.on("contentClick", function(e) { 
    console.log("stage contentClick"); 
}) 

stage.on("click", function(e) { 
    console.log("stage click"); 
}) 

//Both events get fired equally 

은 이미 "contentClick는"단지 무대에서 작동하는 것 같다 것으로 나타났습니다 :

rect.on("contentClick", function(e) { 
    //This never gets fired 
    console.log("rect contentClick"); 
}) 

... 그리고 "contentClick는"cancelBubble 잘 재생되지 않습니다

rect.on("click", function(e) { 
    console.log("rect click"); 
    e.cancelBubble = true; 
}) 

stage.on("contentClick", function(e) { 
    //This fires even though cancelBubble should prevent it 
    console.log("stage contentClick"); 
}) 

이러한 차이점을 제외하고 정확히 "contentClick"은 무엇이며 일반적으로 어떤 용도로 사용됩니까?

감사합니다.

답변

0

contentEvent은 DOM 요소의 이벤트에서 발생합니다. 에 해고 (NO '내용'접두사)

stage.on("contentClick", function(e) { 
    var nativeEvent = e.evt; 
    console.log("stage contentClick", e); 
}); 

기타 이벤트 : 콜백의 첫 번째 인수는 특별한 운동 이벤트 객체, 당신은 (v.5.1.0에 대한) evt 속성을 통해 기본 DOM 이벤트 객체에 액세스 할 수 있습니다 키네틱 노드 이벤트. 데모보기 : http://jsbin.com/pomemo/1/edit

이미지를 클릭 해보십시오. 콘솔 contentClick (캔버스 요소에서 버블 링 됨) 및 click (Kinetic.Image에서 "bubble")의 두 이벤트가 표시됩니다. 그런 다음 빈 공간을 클릭하십시오. contentClickclick 이벤트가 하나만 표시됩니다 (Kinetic.Node를 클릭하지 않았기 때문에)

+0

확인

UIUtils_stageClick = function(event){ // unselect anything, only if we did not click on a card.... clicking on the table background only if (!event.targetNode) { voidFunctions_clearSelection(); } // hide any error message flag or card label tag UIUtils_hideErrorToolTip(); UIUtils_hideCardToolTip(); window.game.stage.draw(); 

가}, 나는 그것을 얻었다! 고맙습니다. –

+0

이미지의 "클릭"이벤트가 발생한 후 contentClick 이벤트를 취소 할 수 있습니까? –

+0

목적을 이해해야합니다. 왜 그것을 필요로합니까? – lavrton

0

특정 노드에서 이벤트가 트리거되면 이벤트의 targetNode 값이 해당 노드 .... 이벤트가 스테이지를 클릭하는 것만으로 트리거되면 targetNode는 이벤트에 설정되지 않습니다.

그래서, targetNode의 존재 여부를 테스트하기 위해 내 핸들러를 설정합니다

관련 문제