@@ -338,7 +338,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
338338 this . bindEvent ( dropdownEditor , 'pointerleave' , this . onPointerEnd ) ;
339339 this . bindEvent ( dropdownEditor , 'pointerdown' , this . onPointerStart ) ;
340340 this . bindEvent ( dropdownEditor , 'pointercancel' , this . onPointerEnd ) ;
341- this . bindEvent ( dropdownEditor , 'keydown' , this . onEditorKeyDown ) ;
342341 // Stop the browser from handling touch events and cancelling the event.
343342 this . bindEvent ( dropdownEditor , 'touchmove' , ( e : Event ) => {
344343 e . preventDefault ( ) ;
@@ -424,26 +423,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
424423 return grid ;
425424 }
426425
427- /**
428- * Handles editor-level keyboard shortcuts.
429- * Ctrl/Cmd+Enter commits and closes; Escape reverts and closes.
430- *
431- * @param e The keydown event.
432- */
433- private onEditorKeyDown ( e : KeyboardEvent ) {
434- const isEscape = e . key === 'Escape' ;
435- const isCommit = e . key === 'Enter' && ( e . ctrlKey || e . metaKey ) ;
436- if ( ! isEscape && ! isCommit ) return ;
437-
438- if ( isEscape && this . initialValue !== null ) {
439- this . setValue ( this . initialValue , false ) ;
440- }
441- Blockly . DropDownDiv . hideIfOwner ( this ) ;
442- Blockly . getFocusManager ( ) . focusNode ( this ) ;
443- e . preventDefault ( ) ;
444- e . stopPropagation ( ) ;
445- }
446-
447426 /**
448427 * Handles keyboard navigation and activation inside the pixel grid.
449428 *
@@ -737,7 +716,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
737716 this . focusedPixelIndex = - 1 ;
738717 this . pointerIsDown = false ;
739718 this . valToPaintWith = undefined ;
740- // Set this.initialValue back to null.
741719 this . initialValue = null ;
742720
743721 Blockly . DropDownDiv . getContentDiv ( ) . classList . remove (
@@ -843,10 +821,11 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
843821 * Resets pointer state (e.g. After either a pointerup event or if the
844822 * gesture is canceled).
845823 *
846- * @param e The pointer event that ended the gesture.
824+ * @param e The pointer event that ended the gesture, when available .
847825 */
848- private onPointerEnd ( e : PointerEvent ) {
826+ private onPointerEnd ( e ? : PointerEvent ) {
849827 if (
828+ e &&
850829 e . currentTarget instanceof HTMLElement &&
851830 e . currentTarget . hasPointerCapture ?.( e . pointerId )
852831 ) {
@@ -938,10 +917,10 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
938917 * @param eventName Name of the event to bind.
939918 * @param callback Function to be called on specified event.
940919 */
941- private bindEvent < E extends Event > (
920+ private bindEvent (
942921 element : HTMLElement ,
943922 eventName : string ,
944- callback : ( e : E ) => void ,
923+ callback : ( e : PointerEvent ) => void ,
945924 ) {
946925 this . boundEvents . push (
947926 Blockly . browserEvents . bind ( element , eventName , this , callback ) ,
0 commit comments