1
|
=== modified file 'src/com/goldencode/p2j/ui/client/TopLevelWindow.java'
|
2
|
--- src/com/goldencode/p2j/ui/client/TopLevelWindow.java 2016-03-07 12:46:23 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/TopLevelWindow.java 2016-03-10 23:39:36 +0000
|
4
|
@@ -37,6 +37,7 @@
|
5
|
** 014 EVL 20160224 Javadoc fixes to make compatible with Oracle Java 8 for Solaris 10.
|
6
|
** 015 HC 20160304 Replaced Window.moveBy() with setPhysicalLocation().
|
7
|
** 016 VIG 20160307 Moved system menus here from WindowGuiImpl, moved init* and create* methods.
|
8
|
+** SBI 20160310 Changed to reuse the common code
|
9
|
*/
|
10
|
|
11
|
package com.goldencode.p2j.ui.client;
|
12
|
@@ -44,6 +45,7 @@
|
13
|
import java.awt.event.*;
|
14
|
import java.io.*;
|
15
|
import java.util.*;
|
16
|
+import java.util.function.Predicate;
|
17
|
|
18
|
import com.goldencode.p2j.ui.*;
|
19
|
import com.goldencode.p2j.ui.chui.*;
|
20
|
@@ -812,19 +814,18 @@
|
21
|
|
22
|
if (mouseSource != null && mouseSource.isDisplayed())
|
23
|
{
|
24
|
- WidgetId id = null;
|
25
|
-
|
26
|
// search for a parent with a valid id
|
27
|
- Widget<O> parent = mouseSource;
|
28
|
- while (parent != null)
|
29
|
+ Widget<O> parent = WidgetRegistry.findAncestor(mouseSource, new Predicate<Widget>()
|
30
|
{
|
31
|
- id = parent.getId();
|
32
|
- if (id != null)
|
33
|
+ @Override
|
34
|
+ public boolean test(Widget t)
|
35
|
{
|
36
|
- break;
|
37
|
+ return UiUtils.getWidgetId(t) != null;
|
38
|
}
|
39
|
- parent = parent.parent();
|
40
|
- }
|
41
|
+ });
|
42
|
+
|
43
|
+ WidgetId id = (parent != null) ? parent.getId() : null;
|
44
|
+
|
45
|
if (id != null)
|
46
|
{
|
47
|
// not all OS-widgets have an ID, skip those
|
48
|
|
49
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java'
|
50
|
--- src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java 2016-03-10 10:52:08 +0000
|
51
|
+++ src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java 2016-03-10 23:38:49 +0000
|
52
|
@@ -972,13 +972,18 @@
|
53
|
else
|
54
|
{
|
55
|
TopLevelWindow<GuiOutputManager> wnd = topLevelWindow();
|
56
|
+
|
57
|
if (wnd != null)
|
58
|
{
|
59
|
- String selection = getSelectedText();
|
60
|
- boolean selectionEmpty = selection == null || selection.isEmpty();
|
61
|
- Menu<GuiOutputManager> menu = wnd.initEditorPopup(this, e, selectionEmpty);
|
62
|
- ((EditorPopupGuiImpl) menu).initEditorItems(selectionEmpty);
|
63
|
- Menu.showPopupMenu(menu, this);
|
64
|
+ NativePoint origin = editor.screenPhysicalLocation();
|
65
|
+ if (editor.physicalBounds().contains(e.getX() - origin.x, e.getY() - origin.y))
|
66
|
+ {
|
67
|
+ String selection = getSelectedText();
|
68
|
+ boolean selectionEmpty = selection == null || selection.isEmpty();
|
69
|
+ Menu<GuiOutputManager> menu = wnd.initEditorPopup(this, e, selectionEmpty);
|
70
|
+ ((EditorPopupGuiImpl) menu).initEditorItems(selectionEmpty);
|
71
|
+ Menu.showPopupMenu(menu, this);
|
72
|
+ }
|
73
|
}
|
74
|
}
|
75
|
}
|
76
|
|
77
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java'
|
78
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-03-10 10:52:08 +0000
|
79
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-03-10 23:40:45 +0000
|
80
|
@@ -18,8 +18,8 @@
|
81
|
** window.
|
82
|
** 003 HC 20151013 NPE fix.
|
83
|
** 004 HC 20151024 Fixed race condition when dispatching mouse events.
|
84
|
-** 005 SBI 20160307 Changed processAction to deliver mouse events to the closest registered widget
|
85
|
-** in the source mouse widget parent's hierarchy.
|
86
|
+** 005 SBI 20160310 Changed processAction/findMouseSource to deliver mouse events to the closest
|
87
|
+** registered widget in the source mouse widget parent's hierarchy.
|
88
|
*/
|
89
|
|
90
|
package com.goldencode.p2j.ui.client.gui.driver.swing;
|
91
|
@@ -37,6 +37,8 @@
|
92
|
import com.goldencode.p2j.ui.WidgetId;
|
93
|
import com.goldencode.p2j.ui.client.*;
|
94
|
import com.goldencode.p2j.ui.client.event.*;
|
95
|
+import com.goldencode.p2j.ui.client.gui.EditorGuiImpl;
|
96
|
+import com.goldencode.p2j.ui.client.gui.LabelGuiImpl;
|
97
|
import com.goldencode.p2j.ui.client.gui.ScrollBarGuiImpl;
|
98
|
import com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl;
|
99
|
import com.goldencode.p2j.ui.client.gui.driver.*;
|
100
|
@@ -286,7 +288,7 @@
|
101
|
{
|
102
|
Widget<?> mouseSource = findMouseSource(e);
|
103
|
// if the widget has changed, send EXITED/ENTERED events
|
104
|
- if (lastHoveredWidget != null && lastHoveredWidget != mouseSource)
|
105
|
+ if (lastHoveredWidget != null && !lastHoveredWidget.getActualBounds().contains(e.getX(), e.getY()))
|
106
|
{
|
107
|
MouseEvent exite = new MouseEvent((Component) e.getSource(),
|
108
|
MouseEvent.MOUSE_EXITED,
|
109
|
@@ -301,7 +303,11 @@
|
110
|
processAction(lastHoveredWidget, exite);
|
111
|
// call this unconditionally, as the widget needs to be notified that it was exit...
|
112
|
tc.postMouseEvent(exite, ews.getWindowId(), UiUtils.getWidgetIdAsInt(lastHoveredWidget));
|
113
|
-
|
114
|
+ lastHoveredWidget = null;
|
115
|
+ }
|
116
|
+ if (lastHoveredWidget != mouseSource
|
117
|
+ && mouseSource!= null && mouseSource.getActualBounds().contains(e.getX(), e.getY()))
|
118
|
+ {
|
119
|
MouseEvent entere = new MouseEvent((Component) e.getSource(),
|
120
|
MouseEvent.MOUSE_ENTERED,
|
121
|
e.getWhen(),
|
122
|
@@ -381,7 +387,43 @@
|
123
|
|
124
|
Widget<?> mouseSource = window.findMouseSource(new MouseEvt(e, window));
|
125
|
|
126
|
- return mouseSource;
|
127
|
+ // find widget in its ancestor's hierarchy that has an id
|
128
|
+ Widget parent = WidgetRegistry.findAncestor(mouseSource, new Predicate<Widget>()
|
129
|
+ {
|
130
|
+ @Override
|
131
|
+ public boolean test(Widget t)
|
132
|
+ {
|
133
|
+ // TODO: to improve/simplify the mouse pointer is over a widget
|
134
|
+ // work around to skip labels
|
135
|
+ return UiUtils.getWidgetId(t) != null && !(LabelGuiImpl.class.equals(t.getClass()));
|
136
|
+ }
|
137
|
+ });
|
138
|
+
|
139
|
+ // TODO: move this widget-specific logic into methods that are implemented in the widget
|
140
|
+ // hierarchy so that we do not have direct references to widget classes in this common code
|
141
|
+
|
142
|
+ // if it is scroll bar or scroll button, then find its scroll pane parent
|
143
|
+ if (parent instanceof ScrollBarGuiImpl ||
|
144
|
+ (parent instanceof Button && parent.parent() instanceof ScrollBarGuiImpl))
|
145
|
+ {
|
146
|
+ parent = WidgetRegistry.findAncestor(parent, new Predicate<Widget>()
|
147
|
+ {
|
148
|
+ @Override
|
149
|
+ public boolean test(Widget t)
|
150
|
+ {
|
151
|
+ return ScrollPaneGuiImpl.class.equals(t.getClass());
|
152
|
+ }
|
153
|
+ });
|
154
|
+ }
|
155
|
+
|
156
|
+ // TODO: move this widget-specific logic into methods that are implemented in the widget
|
157
|
+ // hierarchy so that we do not have direct references to widget classes in this common code
|
158
|
+ if (parent instanceof ScrollPaneGuiImpl && parent.parent() instanceof EditorGuiImpl)
|
159
|
+ {
|
160
|
+ parent = parent.parent();
|
161
|
+ }
|
162
|
+
|
163
|
+ return parent;
|
164
|
}
|
165
|
|
166
|
/**
|
167
|
@@ -421,33 +463,8 @@
|
168
|
return false;
|
169
|
}
|
170
|
|
171
|
- // find widget in its ancestor's hierarchy that has an id
|
172
|
- Widget parent = WidgetRegistry.findAncestor(widget, new Predicate<Widget>()
|
173
|
- {
|
174
|
- @Override
|
175
|
- public boolean test(Widget t)
|
176
|
- {
|
177
|
- return UiUtils.getWidgetId(t) != null;
|
178
|
- }
|
179
|
- });
|
180
|
-
|
181
|
- // TODO: move this widget-specific logic into methods that are implemented in the widget
|
182
|
- // hierarchy so that we do not have direct references to widget classes in this common code
|
183
|
-
|
184
|
- // if it is scroll bar then find its scroll pane parent
|
185
|
- if (parent instanceof ScrollBarGuiImpl)
|
186
|
- {
|
187
|
- parent = WidgetRegistry.findAncestor(parent, new Predicate<Widget>()
|
188
|
- {
|
189
|
- @Override
|
190
|
- public boolean test(Widget t)
|
191
|
- {
|
192
|
- return ScrollPaneGuiImpl.class.equals(t.getClass());
|
193
|
- }
|
194
|
- });
|
195
|
- }
|
196
|
-
|
197
|
- WidgetId wid = UiUtils.getWidgetId(parent);
|
198
|
+
|
199
|
+ WidgetId wid = UiUtils.getWidgetId(widget);
|
200
|
|
201
|
if (wid == null)
|
202
|
{
|
203
|
|
204
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java'
|
205
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-03-10 10:52:08 +0000
|
206
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-03-10 22:29:02 +0000
|
207
|
@@ -14,6 +14,7 @@
|
208
|
** 003 SBI 20151201 Fixed to deliver mouse events to their target widgets (JS client has
|
209
|
** no information about child-parent relations, only widgets z-order.)
|
210
|
** 004 IAS 20160229 Changed first argument for the WidgetRegistry.findAncestor() call
|
211
|
+** 005 SBI 20160104 Fixed the cursor positioning within the editor.
|
212
|
*/
|
213
|
|
214
|
package com.goldencode.p2j.ui.client.gui.driver.web;
|
215
|
@@ -53,7 +54,8 @@
|
216
|
Widget w = tc.getWidget(widgetId);
|
217
|
if (w instanceof AbstractContainer)
|
218
|
{
|
219
|
- NativePoint origin = w.displayPhysicalLocation();
|
220
|
+ // It needs to get the widget's location with respect to the parent window.
|
221
|
+ NativePoint origin = w.screenPhysicalLocation();
|
222
|
Widget target = ((AbstractContainer) w).findMouseSource(
|
223
|
new NativePoint(event.getX() - origin.x, event.getY() - origin.y));
|
224
|
|
225
|
|
226
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js'
|
227
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2016-03-09 16:03:40 +0000
|
228
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2016-03-10 21:26:14 +0000
|
229
|
@@ -19,6 +19,7 @@
|
230
|
** early incorrect dismiss, no need to attach focus listener to click if we
|
231
|
** already have it for press. This confuses the overlay window.
|
232
|
** 006 IAS 20160217 LOAD-MOUSE-POINTER ans SET-WAIT-STATE support
|
233
|
+** 007 SBI 20160310 Added getEvents() to MouseMovable.
|
234
|
**/
|
235
|
|
236
|
"use strict";
|
237
|
|