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
·82 lines (79 loc) · 2.03 KB
/
Copy pathMenu.java
File metadata and controls
executable file
·82 lines (79 loc) · 2.03 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
package javaforce.webui;
/** Menu (place on MenuBar or PopupMenu)
*
* @author pquiring
*/
public class Menu extends MenuItem {
public PopupMenu menu;
private boolean inMenuBar;
private boolean inMenu;
public Menu(String text) {
super(text);
setClass("menu");
menu = new PopupMenu();
add(menu);
addEvent("onmousemove", "onMouseMove(event, this);");
}
public void init() {
if (parent == null) return;
if (parent instanceof MenuBar) {
inMenuBar = true;
}
if (parent instanceof PopupMenu) {
inMenu = true;
}
}
public String html() {
StringBuffer sb = new StringBuffer();
sb.append(super.html());
sb.append(menu.html());
return sb.toString();
}
public void add(MenuItem item) {
menu.add(item);
}
public void onMouseDown(String args[]) {
}
public void onClick(String args[]) {
sendEvent("getpossize", null);
}
public void onPosSize(String args[]) {
super.onPosSize(args);
if (inMenuBar)
menu.setPosition(x, y + height);
else
menu.setPosition(x + width, y);
menu.setVisible(true);
if (inMenuBar) {
client.topPopupMenu = menu;
}
}
public void onMouseMove(String args[]) {
if (inMenu) {
onClick(null, args);
} else if (client.topPopupMenu != null && client.topPopupMenu != menu) {
client.topPopupMenu.setVisible(false);
onClick(null, args);
}
}
public void closeMenu() {
menu.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;
}
}
}