Skip to content

Commit cc89039

Browse files
committed
fixes issue with resize release over applet
1 parent b60190b commit cc89039

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed
Binary file not shown.

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
22

3+
// BH 2023.12.14 fixes resizing into application (making it smaller)
34
// BH 2023.12.13 fixes RIGHT-DRAG and SHIFT-LEFT-DRAG modifier
45
// BH 2023.12.07 fixes mouseUp on body causing (ignorable) error
56
// BH 2023.11.06 adds css touch-action none
@@ -1851,6 +1852,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
18511852
}
18521853

18531854
if (J2S._dmouseOwner && J2S._dmouseOwner.isDragging) {
1855+
// resizing mouse dragged over applet
18541856
if (J2S._dmouseDrag)
18551857
J2S._dmouseDrag(ev);
18561858
else
@@ -1880,9 +1882,14 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
18801882
}
18811883

18821884
var mouseUp = function(who, ev) {
1883-
if (J2S._dmouseOwner) {
1884-
J2S._dmouseOwner.isDragging = false;
1885-
J2S._dmouseOwner = null;
1885+
if (J2S._dmouseOwner && J2S._dmouseOwner.isDragging) {
1886+
// resizing mouse released over applet
1887+
if (J2S._dmouseDrag) {
1888+
J2S._dmouseUp(ev);
1889+
} else {
1890+
System.out.println("move setting dmouseowner null");
1891+
J2S._dmouseOwner = null;
1892+
}
18861893
}
18871894
if (!who || who.applet == null)
18881895
return;
@@ -3185,6 +3192,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
31853192
var down = function(ev) {
31863193
J2S._dmouseOwner = tag;
31873194
J2S._dmouseDrag = drag;
3195+
J2S._dmouseUp = up;
31883196

31893197
tag.isDragging = true; // used by J2S mouse event business
31903198
pageX = Math.round(ev.pageX);
@@ -3236,6 +3244,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
32363244
}
32373245
}, up = function(ev) {
32383246
J2S._dmouseDrag = null;
3247+
J2S._dmouseUp = null;
32393248
if (J2S._dmouseOwner == tag) {
32403249
tag.isDragging = false;
32413250
J2S._dmouseOwner = null

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

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10686,6 +10686,8 @@ return jQuery;
1068610686
})(jQuery,document,"click mousemove mouseup touchmove touchend", "outjsmol");
1068710687
// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
1068810688

10689+
// BH 2023.12.14 fixes resizing into application (making it smaller)
10690+
// BH 2023.12.13 fixes RIGHT-DRAG and SHIFT-LEFT-DRAG modifier
1068910691
// BH 2023.12.07 fixes mouseUp on body causing (ignorable) error
1069010692
// BH 2023.11.06 adds css touch-action none
1069110693
// BH 2023.11.01 adds pointerup, pointerdown, and pointermove to J2S.setMouse
@@ -12372,26 +12374,6 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) {
1237212374
return ignore;
1237312375
};
1237412376

12375-
var getKeyModifiers = function(ev) {
12376-
var modifiers = 0;
12377-
if (ev.shiftKey)
12378-
modifiers |= (1 << 0) | (1 << 6); // InputEvent.SHIFT_MASK +
12379-
// InputEvent.SHIFT_DOWN_MASK;
12380-
if (ev.ctrlKey)
12381-
modifiers |= (1 << 1) | (1 << 7); // InputEvent.CTRL_MASK +
12382-
// InputEvent.CTRL_DOWN_MASK;
12383-
if (ev.metaKey)
12384-
modifiers |= (1 << 2) | (1 << 8); // InputEvent.META_MASK +
12385-
// InputEvent.META_DOWN_MASK;
12386-
if (ev.altKey)
12387-
modifiers |= (1 << 3) | (1 << 9); // InputEvent.ALT_MASK +
12388-
// InputEvent.ALT_DOWN_MASK;
12389-
if (ev.altGraphKey)
12390-
modifiers |= (1 << 5) | (1 << 13); // InputEvent.ALT_GRAPH_MASK +
12391-
// InputEvent.ALT_GRAPH_DOWN_MASK;
12392-
return modifiers;
12393-
}
12394-
1239512377
J2S.setKeyListener = function(who) {
1239612378
J2S.$bind(who, 'keydown keypress keyup', function(ev) {
1239712379
if (doIgnore(ev))
@@ -12556,6 +12538,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1255612538
}
1255712539

1255812540
if (J2S._dmouseOwner && J2S._dmouseOwner.isDragging) {
12541+
// resizing mouse dragged over applet
1255912542
if (J2S._dmouseDrag)
1256012543
J2S._dmouseDrag(ev);
1256112544
else
@@ -12585,9 +12568,14 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1258512568
}
1258612569

1258712570
var mouseUp = function(who, ev) {
12588-
if (J2S._dmouseOwner) {
12589-
J2S._dmouseOwner.isDragging = false;
12590-
J2S._dmouseOwner = null;
12571+
if (J2S._dmouseOwner && J2S._dmouseOwner.isDragging) {
12572+
// resizing mouse released over applet
12573+
if (J2S._dmouseDrag) {
12574+
J2S._dmouseUp(ev);
12575+
} else {
12576+
System.out.println("move setting dmouseowner null");
12577+
J2S._dmouseOwner = null;
12578+
}
1259112579
}
1259212580
if (!who || who.applet == null)
1259312581
return;
@@ -12864,7 +12852,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1286412852
// and also recognize a drag (503 + buttons pressed
1286512853
var modifiers = 0;
1286612854
if (id == 503) {
12867-
modifiers = ev.buttons << 10;
12855+
modifiers = (ev.buttons == 0 ? 0 : ev.buttons == 2 ? (1 << 12) : (1 << 10));
1286812856
} else {
1286912857
switch (ev.button) {
1287012858
default:
@@ -12888,6 +12876,26 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1288812876
return modifiers | getKeyModifiers(ev);
1288912877
}
1289012878

12879+
var getKeyModifiers = function(ev) {
12880+
var modifiers = 0;
12881+
if (ev.shiftKey)
12882+
modifiers |= (1 << 0) | (1 << 6); // InputEvent.SHIFT_MASK +
12883+
// InputEvent.SHIFT_DOWN_MASK;
12884+
if (ev.ctrlKey)
12885+
modifiers |= (1 << 1) | (1 << 7); // InputEvent.CTRL_MASK +
12886+
// InputEvent.CTRL_DOWN_MASK;
12887+
if (ev.metaKey)
12888+
modifiers |= (1 << 2) | (1 << 8); // InputEvent.META_MASK +
12889+
// InputEvent.META_DOWN_MASK;
12890+
if (ev.altKey)
12891+
modifiers |= (1 << 3) | (1 << 9); // InputEvent.ALT_MASK +
12892+
// InputEvent.ALT_DOWN_MASK;
12893+
if (ev.altGraphKey)
12894+
modifiers |= (1 << 5) | (1 << 13); // InputEvent.ALT_GRAPH_MASK +
12895+
// InputEvent.ALT_GRAPH_DOWN_MASK;
12896+
return modifiers;
12897+
}
12898+
1289112899
var getXY = function(who, ev, id) {
1289212900
// id 0, 502, or 503 only
1289312901
if (!who.applet._ready || J2S._touching && ev.type.indexOf("touch") < 0)
@@ -13870,6 +13878,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1387013878
var down = function(ev) {
1387113879
J2S._dmouseOwner = tag;
1387213880
J2S._dmouseDrag = drag;
13881+
J2S._dmouseUp = up;
1387313882

1387413883
tag.isDragging = true; // used by J2S mouse event business
1387513884
pageX = Math.round(ev.pageX);
@@ -13921,6 +13930,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1392113930
}
1392213931
}, up = function(ev) {
1392313932
J2S._dmouseDrag = null;
13933+
J2S._dmouseUp = null;
1392413934
if (J2S._dmouseOwner == tag) {
1392513935
tag.isDragging = false;
1392613936
J2S._dmouseOwner = null

0 commit comments

Comments
 (0)