@@ -519,6 +519,8 @@ define([
519519 // blockContainer.resetOptionPage();
520520 blockContainer . setFocusedPageType ( FOCUSED_PAGE_TYPE . NULL ) ;
521521 } ) ;
522+
523+ $ ( vpCommon . wrapSelector ( '' ) )
522524
523525 /** Create block buttons page를 클릭했을 때 */
524526 $ ( vpCommon . wrapSelector ( VP_CLASS_PREFIX + VP_CLASS_APIBLOCK_BUTTONS ) ) . click ( function ( event ) {
@@ -574,7 +576,8 @@ define([
574576 ctrlKey = 17 ,
575577 cmdKey = 91 ,
576578 vKey = 86 ,
577- cKey = 67 ;
579+ cKey = 67 ,
580+ escKey = 27 ;
578581
579582 $ ( document ) . keydown ( function ( e ) {
580583 if ( e . keyCode == ctrlKey || e . keyCode == cmdKey ) {
@@ -583,12 +586,43 @@ define([
583586 } ) . keyup ( function ( e ) {
584587 if ( e . keyCode == ctrlKey || e . keyCode == cmdKey ) {
585588 ctrlDown = false ;
589+ console . log ( blockContainer . getFocusedPageType ( ) ) ;
590+ }
591+ if ( e . keyCode == escKey ) {
592+ // close popup on esc
593+ if ( blockContainer . getFocusedPageType ( ) != FOCUSED_PAGE_TYPE . NULL ) {
594+ blockContainer . appsMenu . close ( ) ;
595+ }
586596 }
587597 } ) . click ( function ( e ) {
598+ // click event on jupyter side
599+ if ( $ ( '#notebook' ) . has ( e . target ) . length > 0 ) {
600+ blockContainer . setFocusedPageType ( FOCUSED_PAGE_TYPE . NULL ) ;
601+ }
602+ // click event on visual python menu tab & button box
603+ if ( $ ( vpCommon . wrapSelector ( '.vp-apiblock-tab-header' ) ) . has ( e . target ) . length > 0
604+ || $ ( vpCommon . wrapSelector ( '.vp-apiblock-board-button-container' ) ) . has ( e . target ) . length > 0 ) {
605+ blockContainer . setFocusedPageType ( FOCUSED_PAGE_TYPE . BUTTONS ) ;
606+ }
607+ // click event on popup menu
608+ if ( $ ( vpCommon . wrapSelector ( '.vp-ds' ) ) . has ( e . target ) . length > 0
609+ || $ ( vpCommon . wrapSelector ( '.vp-fe' ) ) . has ( e . target ) . length > 0
610+ || $ ( vpCommon . wrapSelector ( '.vp-pp' ) ) . has ( e . target ) . length > 0
611+ || $ ( vpCommon . wrapSelector ( '.vp-ds-btn-box' ) ) . has ( e . target ) . length > 0
612+ || $ ( vpCommon . wrapSelector ( '.vp-fe-btn-box' ) ) . has ( e . target ) . length > 0
613+ || $ ( vpCommon . wrapSelector ( '.vp-pp-btn-box' ) ) . has ( e . target ) . length > 0 ) {
614+ blockContainer . setFocusedPageType ( FOCUSED_PAGE_TYPE . OPTION ) ;
615+ }
616+
588617 // check modified
589618 blockContainer . checkModified ( ) ;
590619 } ) ;
591620
621+ // focus event on codemirror of jupyter side
622+ $ ( document ) . on ( 'focus' , '#notebook .CodeMirror' , function ( e ) {
623+ blockContainer . setFocusedPageType ( FOCUSED_PAGE_TYPE . NULL ) ;
624+ } ) ;
625+
592626 $ ( document ) . change ( $ ( vpCommon . wrapSelector ( '.vp-apiblock-option input' ) ) , function ( ) {
593627 // check modified
594628 blockContainer . checkModified ( ) ;
0 commit comments