11// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
22
3+ // BH 2023.12.13 fixes RIGHT-DRAG and SHIFT-LEFT-DRAG modifier
34// BH 2023.12.07 fixes mouseUp on body causing (ignorable) error
45// BH 2023.11.06 adds css touch-action none
56// BH 2023.11.01 adds pointerup, pointerdown, and pointermove to J2S.setMouse
@@ -1686,26 +1687,6 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) {
16861687 return ignore ;
16871688 } ;
16881689
1689- var getKeyModifiers = function ( ev ) {
1690- var modifiers = 0 ;
1691- if ( ev . shiftKey )
1692- modifiers |= ( 1 << 0 ) | ( 1 << 6 ) ; // InputEvent.SHIFT_MASK +
1693- // InputEvent.SHIFT_DOWN_MASK;
1694- if ( ev . ctrlKey )
1695- modifiers |= ( 1 << 1 ) | ( 1 << 7 ) ; // InputEvent.CTRL_MASK +
1696- // InputEvent.CTRL_DOWN_MASK;
1697- if ( ev . metaKey )
1698- modifiers |= ( 1 << 2 ) | ( 1 << 8 ) ; // InputEvent.META_MASK +
1699- // InputEvent.META_DOWN_MASK;
1700- if ( ev . altKey )
1701- modifiers |= ( 1 << 3 ) | ( 1 << 9 ) ; // InputEvent.ALT_MASK +
1702- // InputEvent.ALT_DOWN_MASK;
1703- if ( ev . altGraphKey )
1704- modifiers |= ( 1 << 5 ) | ( 1 << 13 ) ; // InputEvent.ALT_GRAPH_MASK +
1705- // InputEvent.ALT_GRAPH_DOWN_MASK;
1706- return modifiers ;
1707- }
1708-
17091690 J2S . setKeyListener = function ( who ) {
17101691 J2S . $bind ( who , 'keydown keypress keyup' , function ( ev ) {
17111692 if ( doIgnore ( ev ) )
@@ -2178,7 +2159,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
21782159 // and also recognize a drag (503 + buttons pressed
21792160 var modifiers = 0 ;
21802161 if ( id == 503 ) {
2181- modifiers = ev . buttons << 10 ;
2162+ modifiers = ( ev . buttons == 0 ? 0 : ev . buttons == 2 ? ( 1 << 12 ) : ( 1 << 10 ) ) ;
21822163 } else {
21832164 switch ( ev . button ) {
21842165 default :
@@ -2202,6 +2183,26 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
22022183 return modifiers | getKeyModifiers ( ev ) ;
22032184 }
22042185
2186+ var getKeyModifiers = function ( ev ) {
2187+ var modifiers = 0 ;
2188+ if ( ev . shiftKey )
2189+ modifiers |= ( 1 << 0 ) | ( 1 << 6 ) ; // InputEvent.SHIFT_MASK +
2190+ // InputEvent.SHIFT_DOWN_MASK;
2191+ if ( ev . ctrlKey )
2192+ modifiers |= ( 1 << 1 ) | ( 1 << 7 ) ; // InputEvent.CTRL_MASK +
2193+ // InputEvent.CTRL_DOWN_MASK;
2194+ if ( ev . metaKey )
2195+ modifiers |= ( 1 << 2 ) | ( 1 << 8 ) ; // InputEvent.META_MASK +
2196+ // InputEvent.META_DOWN_MASK;
2197+ if ( ev . altKey )
2198+ modifiers |= ( 1 << 3 ) | ( 1 << 9 ) ; // InputEvent.ALT_MASK +
2199+ // InputEvent.ALT_DOWN_MASK;
2200+ if ( ev . altGraphKey )
2201+ modifiers |= ( 1 << 5 ) | ( 1 << 13 ) ; // InputEvent.ALT_GRAPH_MASK +
2202+ // InputEvent.ALT_GRAPH_DOWN_MASK;
2203+ return modifiers ;
2204+ }
2205+
22052206 var getXY = function ( who , ev , id ) {
22062207 // id 0, 502, or 503 only
22072208 if ( ! who . applet . _ready || J2S . _touching && ev . type . indexOf ( "touch" ) < 0 )
0 commit comments