Skip to content

Commit cf8b7f9

Browse files
hansonrhansonr
authored andcommitted
fixes problem with modified mouse-drag
shift key on mouse drag not recorded in event extended modifiers, resulting in LightweightDispatcher not considering it a "mouse grab"
1 parent 2147e6d commit cf8b7f9

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed
146 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181220001942
1+
20181220025341
146 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181220001942
1+
20181220025341

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,8 +2204,10 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
22042204
"translateY(-" + itop + "%)" + (iscale == null ? "" : iscale));
22052205
} else {
22062206
DOMNode.setSize(menuAnchorNode, wCtr + margins.left + margins.right, h);
2207-
DOMNode.setStyles(textNode, "top", "50%", "transform", "translateY(-80%)");
2208-
DOMNode.setStyles(iconNode, "top", "50%", "transform", "translateY(-90%) scale(0.6,0.6)");
2207+
if (actionNode != null) {
2208+
DOMNode.setStyles(textNode, "top", "50%", "transform", "translateY(-80%)");
2209+
DOMNode.setStyles(iconNode, "top", "50%", "transform", "translateY(-90%) scale(0.6,0.6)");
2210+
}
22092211
}
22102212
}
22112213

sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// j2sCore.js (based on JmolCore.js
22

3+
// BH 12/20/2018 fixes mouse event extended modifiers for drag operation
34
// BH 11/7/2018 adds J2S.addDirectDatabaseCall(domain)
45
// BH 9/18/2018 fixes data.getBytes() not qualified
56
// BH 8/12/2018 adding J2S.onClazzLoaded(i,msg) hook for customization
@@ -1804,24 +1805,28 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
18041805

18051806
var getMouseModifiers = function(ev, id) {
18061807
// id needed to properly not assign the InputEvent.ButtonX_DOWN_MASK for an UP operation
1808+
// and also recognize a drag (503 + buttons pressed
18071809
var modifiers = 0;
1808-
if (id != 503)
1809-
switch (ev.button) {
1810-
default:
1811-
ev.button = 0;
1812-
// fall through
1813-
case 0:
1814-
modifiers = (1 << 4) | (id ? 0 : (1 << 10));// InputEvent.BUTTON1 +
1815-
// InputEvent.BUTTON1_DOWN_MASK;
1816-
break;
1817-
case 1:
1818-
modifiers = (1 << 3) | (id ? 0 : (1 << 11));// InputEvent.BUTTON2 +
1819-
// InputEvent.BUTTON2_DOWN_MASK;
1820-
break;
1821-
case 2:
1822-
modifiers = (1 << 2) | (id ? 0 : (1 << 12));// InputEvent.BUTTON3 +
1823-
// InputEvent.BUTTON3_DOWN_MASK;
1824-
break;
1810+
if (id == 503) {
1811+
modifiers = ev.buttons << 10;
1812+
} else {
1813+
switch (ev.button) {
1814+
default:
1815+
ev.button = 0;
1816+
// fall through
1817+
case 0:
1818+
modifiers = (1 << 4) | (id ? 0 : (1 << 10));// InputEvent.BUTTON1 +
1819+
// InputEvent.BUTTON1_DOWN_MASK;
1820+
break;
1821+
case 1:
1822+
modifiers = (1 << 3) | (id ? 0 : (1 << 11));// InputEvent.BUTTON2 +
1823+
// InputEvent.BUTTON2_DOWN_MASK;
1824+
break;
1825+
case 2:
1826+
modifiers = (1 << 2) | (id ? 0 : (1 << 12));// InputEvent.BUTTON3 +
1827+
// InputEvent.BUTTON3_DOWN_MASK;
1828+
break;
1829+
}
18251830
}
18261831
return modifiers | J2S.getKeyModifiers(ev);
18271832
}

0 commit comments

Comments
 (0)