Skip to content

Commit 2525173

Browse files
committed
j2sMenu fixes
1 parent 75a8ae9 commit 2525173

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ public static class JSFileSystemProvider extends FileSystemProvider {
986986

987987
private static Map<String, JSFileSystem> fsMap = new Hashtable<>();
988988

989-
/** Could be "file" or "http" or "https"
989+
/** Could be "file" or "jar" or "http" or "https"
990990
*/
991991
private String scheme;
992992

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public interface JQEvent {
3333
public abstract JQueryObject addClass(String name);
3434
public abstract JQueryObject removeClass(String name);
3535

36-
public abstract void show();
37-
public abstract void hide();
36+
public abstract JQueryObject show();
37+
public abstract JQueryObject hide();
3838

3939
public abstract void resize(Object fHandleResize);
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ protected DOMNode createItem(String type, DOMNode buttonNode) {
150150
menuAnchorNode = newDOMObject("div", id + "_a");// this needed? , "tabindex", "8");
151151
if (type != "_bar") {
152152
addClass(menuAnchorNode, "a");
153-
DOMNode.setStyles(menuAnchorNode, "margin", "1px 2px 1px 2px");
153+
// DOMNode.setStyles(menuAnchorNode, "margin", "1px 2px 1px 2px", "height", "1em");
154154
}
155155
itemNode.appendChild(menuAnchorNode);
156156
setDoPropagate();

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ void propertyChangedFromListener(PropertyChangeEvent e, String prop) {
13671367
protected void propertyChangedCUI(PropertyChangeEvent e, String prop) {
13681368
// don't want to update a menu until we have to, after its place is set
13691369
// and we know it is not a JMenuBar menu
1370-
if (!isMenu && cellComponent == null)
1370+
if (allowPropertyUpdate() && cellComponent == null)
13711371
getDOMNode();
13721372

13731373
switch (prop) {
@@ -1436,6 +1436,11 @@ protected void propertyChangedCUI(PropertyChangeEvent e, String prop) {
14361436
}
14371437
}
14381438

1439+
protected boolean allowPropertyUpdate() {
1440+
return true;
1441+
}
1442+
1443+
14391444
protected void setMnemonic(int newValue) {
14401445
// need to handle non-menu mnemonics as well
14411446
if (newValue == mnemonic || domNode == null)
@@ -2539,8 +2544,12 @@ protected void setIconAndText(String prop, Icon icon, int gap, String text) {
25392544
// that for a <button> element to properly align vertically,
25402545
// the font must be set for the button element, not in a child element.
25412546

2542-
setCssFont(domNode, getFont()); // for vertical centering
2543-
setCssFont(textNode, getFont());
2547+
Font f = getFont();
2548+
setCssFont(domNode, f); // for vertical centering
2549+
setCssFont(textNode, f);
2550+
if (menuAnchorNode != null) {
2551+
setCssFont(menuAnchorNode, f); // for vertical centering
2552+
}
25442553
if (!isHTML) {
25452554
/** @j2sNative text = text.replace(C$.reLT, "&lt;").replace(C$.reSpace, "\u00A0");*/
25462555
}
@@ -2898,7 +2907,7 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
28982907
addJSKeyVal(cssIcon, "top", top + "%", "transform",
28992908
"translateY(-" + itop + "%)" + (iscale == null ? "" : iscale));
29002909
} else {
2901-
DOMNode.setStyles(menuAnchorNode, "height", h + "px");
2910+
DOMNode.setStyles(menuAnchorNode, "height", "1em");
29022911
// if (wIcon > 0)
29032912
// addJSKeyVal(cssTxt, "top", "50%", "transform", "translateY(-50%)");
29042913
addJSKeyVal(cssIcon, "top", "50%", "transform", "translateY(-80%) scale(0.6,0.6)");
@@ -3605,7 +3614,7 @@ public void clearPaintPath() {
36053614
JSComponent c = jc;
36063615
while (c != null) {
36073616
JSComponentUI ui = c.秘getUI();
3608-
if (ui == null)
3617+
if (ui == null || ui.isWindow)
36093618
return;
36103619
ui.inPaintPath = true;
36113620
c.秘setPaintsSelf(JSComponent.PAINTS_SELF_ALWAYS);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public DOMNode updateDOMNode() {
5757
@Override
5858
public void propertyChangedFromListener(PropertyChangeEvent e, String prop) {
5959
// System.out.println("JSMenuUI prop = " + prop + " " + jm.getText());
60+
if (jc.getTopLevelAncestor() != null)
61+
updateDOMNode(); // font changes
6062
super.propertyChangedFromListener(e, prop);
6163
}
6264

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,10 @@ public static void processJ2SMenuCmd(Object[] data) {
11961196

11971197
int eventID = 0;
11981198

1199-
// System.out.println("pm " + trigger);
1199+
// System.out.println("pm " + trigger);
12001200
switch (trigger) {
1201+
case "_hidePopupMenu":
1202+
case "_hide":
12011203
case "clearOut":
12021204
case "collapse":
12031205
case "expand":
@@ -1217,8 +1219,6 @@ public static void processJ2SMenuCmd(Object[] data) {
12171219
case "refresh":
12181220
case "select":
12191221
case "_activate":
1220-
case "_hide":
1221-
case "_hidePopupMenu":
12221222
case "_move":
12231223
case "_show":
12241224
case "_startOpening":
@@ -1285,7 +1285,7 @@ public static void closeAllMenus() {
12851285
lastInvoker.requestFocus();
12861286
lastInvoker = null;
12871287
}
1288-
JSUtil.jQuery.$(".ui-j2smenu").hide();
1288+
JSUtil.jQuery.$(".ui-j2smenu").hide().attr("aria-hidden","true").attr("aria-expanded","false");
12891289
JSUtil.jQuery.$(".ui-j2smenu-node").removeClass("ui-state-active").removeClass("ui-state-focus");
12901290
}
12911291

0 commit comments

Comments
 (0)