forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.java
More file actions
executable file
·88 lines (84 loc) · 2.25 KB
/
Copy pathMenu.java
File metadata and controls
executable file
·88 lines (84 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package javaforce.webui;
/** Menu (place on MenuBar or PopupMenu)
*
* @author pquiring
*/
import javaforce.webui.event.*;
public class Menu extends MenuItem {
public PopupMenu popupMenu;
private boolean inMenuBar;
private boolean inMenu;
public Menu(String text) {
super(text);
setClass("menu");
popupMenu = new PopupMenu();
add(popupMenu);
addEvent("onmousemove", "onMouseMove(event, this);");
}
public void init() {
super.init();
if (parent == null) {
System.out.println("Error:Menu.parent == null");
}
else if (parent instanceof MenuBar) {
inMenuBar = true;
}
else if (parent instanceof PopupMenu) {
inMenu = true;
}
else {
System.out.println("Error:Menu.parent type unknown");
}
}
public String html() {
StringBuilder sb = new StringBuilder();
sb.append(super.html());
sb.append(popupMenu.html());
return sb.toString();
}
public void add(MenuItem item) {
popupMenu.add(item);
}
public void onMouseDown(String[] args) {
}
public void onClick(String[] args, MouseEvent me) {
sendEvent("getpossize", null);
}
public void onPosSize(String[] args) {
super.onPosSize(args);
if (inMenuBar)
popupMenu.setPosition(x, y + height);
else
popupMenu.setPosition(x + width, y);
popupMenu.setVisible(true);
if (inMenuBar) {
client.topPopupMenu = popupMenu;
}
}
public void onMouseMove(String[] args) {
if (!inMenu && client.topPopupMenu != null && client.topPopupMenu != popupMenu) {
client.topPopupMenu.setVisible(false);
}
onClick(args, null);
}
public void closeMenu() {
popupMenu.setVisible(false);
}
public static void onMouseDownBody(WebUIClient client, String[] args) {
//args : p=x,y
/*
System.out.println("args=" + args.length);
String f[] = args[0].substring(2).split(",");
int mx = Integer.valueOf(f[0]);
int my = Integer.valueOf(f[0]);
*/
if (!client.popupMenuMouseDown) {
if (client.topPopupMenu != null) {
client.topPopupMenu.setVisible(false);
client.topPopupMenu = null;
}
} else {
client.popupMenuMouseDown = false;
}
}
}