Skip to content

Commit 8a1af7e

Browse files
hansonrhansonr
authored andcommitted
menu, scrollbar fixes
1 parent 940d5be commit 8a1af7e

26 files changed

+229
-76
lines changed
1.6 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181119153133
1+
20181120221948
1.6 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181119153133
1+
20181120221948
1.6 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/javax/swing/JMenu.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,9 +823,9 @@ public void remove(int pos) {
823823
*/
824824
@Override
825825
public void remove(Component c) {
826-
if (c instanceof JMenuItem)
827-
if (popupMenu != null)
828-
popupMenu.remove(c);
826+
// why did I add this? BH 2018 if (c instanceof JMenuItem)
827+
// if (popupMenu != null)
828+
// popupMenu.remove(c);
829829
if (popupMenu != null)
830830
popupMenu.remove(c);
831831
}

sources/net.sf.j2s.java.core/src/swingjs/JSFrameViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private HTML5Canvas newCanvas(int width, int height, RootPaneContainer window) {
230230
}
231231
DOMNode rootNode = (root == null ? null : ((JSComponentUI) root.getUI()).domNode);
232232
if (rootNode != null)
233-
DOMNode.remove(canvas);
233+
DOMNode.dispose(canvas);
234234
display = canvasId = appletViewer.appletName + "_canvas" + ++canvasCount;
235235
canvas = (HTML5Canvas) DOMNode.createElement("canvas", canvasId);
236236
if (userFramedApplet != null) {

sources/net.sf.j2s.java.core/src/swingjs/JSKeyEvent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ public static JSKeyEvent newJSKeyEvent(JComponent source, Object jQueryEvent, bo
4545
: evType == "keypress" ? KEY_TYPED
4646
: evType == "keyup" ? KEY_RELEASED
4747
: 0);
48+
if (id == 0)
49+
return null;
4850
int keyCode = getJavaKeyCode(jskeyCode, jskey);
4951
char keyChar = getJavaKeyChar(keyCode, jskey);
50-
return (id == 0 || keyChar == CHAR_UNDEFINED && id == KEY_TYPED ? null
52+
return (keyChar == CHAR_UNDEFINED && id == KEY_TYPED ? null
5153
: new JSKeyEvent(source, jQueryEvent, id,
5254
(id == KEY_TYPED ? JSKeyEvent.VK_UNDEFINED : keyCode),
5355
keyChar,

sources/net.sf.j2s.java.core/src/swingjs/a2s/A2SEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ public void run() {
4040
Event e = this.e;
4141
Component target = (Component) this.target;
4242
if (target instanceof Container) {
43-
target = ((Container)target).getMouseEventTarget(e.x, e.y, true, null, false);
44-
Component parent = target;
43+
Component parent = ((Container)target).getMouseEventTarget(e.x, e.y, true, null, false);
44+
// on a focus-out event, e.x or e.y may be negative
45+
if (parent != null)
46+
target = parent;
4547
while (parent != null && parent != this.target) {
4648
e.x -= parent.getX();
4749
e.y -= parent.getY();

sources/net.sf.j2s.java.core/src/swingjs/api/js/DOMNode.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public abstract class DOMNode {
2828
// "abstract" in the sense that these are the exact calls to JavaScript
2929

3030
public abstract void appendChild(DOMNode node);
31+
32+
public abstract DOMNode removeChild(DOMNode node);
3133

3234
public abstract boolean hasFocus();
3335

@@ -249,10 +251,32 @@ public static int getWidth(DOMNode node) {
249251
* @param node
250252
* @return parent or null
251253
*/
252-
public static void remove(DOMNode node) {
254+
public static void dispose(DOMNode node) {
253255
if (node != null)
254256
JSUtil.jQuery.$(node).remove();
255257
}
258+
259+
/**
260+
* Just remove the node; don't
261+
* @param node
262+
*/
263+
public static void remove(DOMNode node) {
264+
265+
// NOTE: IE does not have node.remove()
266+
267+
DOMNode p = getParent(node);
268+
if (p != null)
269+
p.removeChild(node);
270+
}
271+
272+
public static void detachAll(DOMNode node) {
273+
/**
274+
* @j2sNative
275+
* if(node)
276+
* while(node.lastChild)
277+
* node.removeChild(node.lastChild);
278+
*/
279+
}
256280

257281
/**
258282
* jQuery detach() + append()
@@ -266,7 +290,8 @@ public static DOMNode transferTo(DOMNode node, DOMNode container) {
266290
return null;
267291
DOMNode p = getParent(node);
268292
try {
269-
JSUtil.jQuery.$(node).detach();
293+
if (p != null)
294+
JSUtil.jQuery.$(node).detach();
270295
} catch (Throwable e) {
271296
// ignore
272297
}

0 commit comments

Comments
 (0)