@@ -563,33 +563,35 @@ class RhythmRuler {
563563 const that = this ;
564564 this . _dissectNumber . onclick = ( event ) => {
565565 const values = activity . beginnerMode ? [ 2 , 3 , 4 ] : [ 2 , 3 , 4 , 5 , 7 ] ;
566-
566+
567567 const menuDiv = docById ( 'wheelDivptm' ) ;
568568 menuDiv . innerHTML = '' ;
569-
569+
570570 menuDiv . style . display = '' ;
571571 const x = event . clientX - 50 ;
572572 const y = event . clientY - 50 ;
573573 menuDiv . style . position = 'absolute' ;
574574 menuDiv . style . left = Math . min ( activity . canvas . width - 200 , Math . max ( 0 , x ) ) + 'px' ;
575575 menuDiv . style . top = Math . min ( activity . canvas . height - 250 , Math . max ( 0 , y ) ) + 'px' ;
576-
577- const wheelNav = new wheelnav ( 'wheelDivptm' , null , 200 , 200 ) ;
576+
577+ const wheelNav = new wheelnav ( 'wheelDivptm' , null , 150 , 150 ) ;
578578 wheelNav . colors = platformColor . wheelcolors ;
579579 wheelNav . slicePathFunction = slicePath ( ) . DonutSlice ;
580580 wheelNav . slicePathCustom = slicePath ( ) . DonutSliceCustomization ( ) ;
581581 wheelNav . sliceSelectedPathCustom = wheelNav . slicePathCustom ;
582582 wheelNav . sliceInitPathCustom = wheelNav . slicePathCustom ;
583583 wheelNav . clickModeRotate = false ;
584+ wheelNav . navItemsSize = 30 ;
584585
585586 const exitMenu = ( ) => {
586587 menuDiv . style . display = 'none' ;
587588 document . removeEventListener ( 'click' , handleOutside ) ;
589+ document . removeEventListener ( 'keydown' , handleKeydown ) ;
588590 if ( wheelNav ) {
589591 wheelNav . removeWheel ( ) ;
590592 }
591593 } ;
592-
594+
593595 // Click outside to close
594596 const handleOutside = ( e ) => {
595597 if ( ! menuDiv . contains ( e . target ) && e . target !== that . _dissectNumber ) {
@@ -599,27 +601,7 @@ class RhythmRuler {
599601 setTimeout ( ( ) => {
600602 document . addEventListener ( 'click' , handleOutside ) ;
601603 } , 0 ) ;
602-
603- // Configure center button for close
604- wheelNav . centerButton = true ;
605- wheelNav . centerButtonRadius = 25 ;
606- wheelNav . centerButtonHover = true ;
607- wheelNav . centerButtonClickable = true ;
608- wheelNav . centerButtonCallback = exitMenu ;
609- wheelNav . centerButtonContent = '×' ;
610-
611- const labels = values . map ( v => v . toString ( ) ) ;
612- wheelNav . initWheel ( labels ) ;
613- wheelNav . createWheel ( ) ;
614-
615- // Add click handlers for numbers
616- for ( let i = 0 ; i < values . length ; i ++ ) {
617- wheelNav . navItems [ i ] . navigateFunction = ( ) => {
618- that . _dissectNumber . value = values [ i ] ;
619- that . _update ( ) ;
620- exitMenu ( ) ;
621- } ;
622- }
604+
623605 // manual entry
624606 const inputDiv = document . createElement ( 'div' ) ;
625607 inputDiv . style . position = 'absolute' ;
@@ -631,7 +613,7 @@ class RhythmRuler {
631613 input . min = '2' ;
632614 input . max = '128' ;
633615 input . value = that . _dissectNumber . value ;
634-
616+
635617 input . oninput = ( ) => {
636618 if ( input . value . length > 3 ) {
637619 input . value = input . value . slice ( 0 , 3 ) ;
@@ -641,13 +623,44 @@ class RhythmRuler {
641623 if ( value < 2 ) input . value = '2' ;
642624 if ( value > 128 ) input . value = '128' ;
643625 } ;
626+
644627 input . onchange = ( ) => {
645628 that . _dissectNumber . value = input . value ;
646- that . _update ( ) ;
647629 exitMenu ( ) ;
648630 } ;
649631 inputDiv . appendChild ( input ) ;
650632 menuDiv . appendChild ( inputDiv ) ;
633+
634+ // enter key project can't run
635+ const handleKeydown = ( e ) => {
636+ if ( e . key === 'Enter' ) {
637+ // console.log('enter');
638+ e . preventDefault ( ) ;
639+ input . blur ( ) ;
640+ exitMenu ( ) ;
641+ }
642+ } ;
643+ document . addEventListener ( 'keydown' , handleKeydown ) ;
644+
645+ // Configure center button for close
646+ wheelNav . centerButton = true ;
647+ wheelNav . centerButtonRadius = 25 ;
648+ wheelNav . centerButtonHover = true ;
649+ wheelNav . centerButtonClickable = true ;
650+ wheelNav . centerButtonCallback = exitMenu ;
651+ wheelNav . centerButtonContent = '×' ;
652+
653+ const labels = values . map ( v => v . toString ( ) ) ;
654+ wheelNav . initWheel ( labels ) ;
655+ wheelNav . createWheel ( ) ;
656+
657+ // Add click handlers for numbers
658+ for ( let i = 0 ; i < values . length ; i ++ ) {
659+ wheelNav . navItems [ i ] . navigateFunction = ( ) => {
660+ that . _dissectNumber . value = values [ i ] ;
661+ exitMenu ( ) ;
662+ } ;
663+ }
651664 } ;
652665
653666 // Remove mouseout handler
0 commit comments