24 |
24 |
** 010 EVL 20151010 Fix for thumb drawing issues. Also reworked image loader specifically for
|
25 |
25 |
** small images. Optimization for button painting on mouse press, release. In
|
26 |
26 |
** these cases we do not need to repaint whole window.
|
|
27 |
** 011 EVL 20151124 The button pressed state needs repaint() call to properly display pressed mode
|
|
28 |
** when running indide drop-down life cycle. Improved mouse handling, in 4GL
|
|
29 |
** if to press mouse, move inside button and release - this generates click. So
|
|
30 |
** we have to track the mouse release, not click.
|
27 |
31 |
*/
|
28 |
32 |
|
29 |
33 |
package com.goldencode.p2j.ui.client.gui;
|
... | ... | |
31 |
35 |
// this usage of AWT events is intentional, they are being used separately from the
|
32 |
36 |
// AWT/Swing event model itself; no other AWT/Swing usage is occurring in this class
|
33 |
37 |
import java.awt.event.MouseEvent;
|
|
38 |
import java.util.concurrent.*;
|
34 |
39 |
|
35 |
40 |
import com.goldencode.p2j.ui.*;
|
36 |
41 |
import com.goldencode.p2j.ui.chui.ThinClient;
|
... | ... | |
67 |
72 |
/** Button state */
|
68 |
73 |
boolean up = true;
|
69 |
74 |
|
|
75 |
/** Executor for handling mouse input. */
|
|
76 |
private static ExecutorService mouseInputExecutor = Executors.newSingleThreadExecutor();
|
|
77 |
|
70 |
78 |
/**
|
71 |
79 |
* This constructor creates a scroll bar button.
|
72 |
80 |
*
|
... | ... | |
198 |
206 |
}
|
199 |
207 |
|
200 |
208 |
/**
|
201 |
|
* Notification of a mouse clicked event occurred for this widget.
|
202 |
|
*
|
203 |
|
* @param e
|
204 |
|
* The mouse event.
|
205 |
|
*/
|
206 |
|
@Override
|
207 |
|
public void mouseClicked(MouseEvent e)
|
208 |
|
{
|
209 |
|
// check if the scrollbar widget is enabled
|
210 |
|
if (owner.isEnabled())
|
211 |
|
{
|
212 |
|
// call scroll bar
|
213 |
|
owner.onButtonClick(position, false);
|
214 |
|
}
|
215 |
|
}
|
216 |
|
|
217 |
|
/**
|
218 |
209 |
* Notification of a mouse pressed event occurred for this widget.
|
219 |
210 |
*
|
220 |
211 |
* @param e
|
... | ... | |
227 |
218 |
if (owner.isEnabled())
|
228 |
219 |
{
|
229 |
220 |
up = false;
|
230 |
|
refresh();
|
|
221 |
// need to use repaint() here instead of refresh() because for example inside combo-box
|
|
222 |
// drop-down standalone event loop the screen synchronization is not happening
|
|
223 |
repaint();
|
|
224 |
|
|
225 |
// for holding mouse we need to genereate scroll events
|
|
226 |
/* mouseInputExecutor.execute(new Runnable()
|
|
227 |
{
|
|
228 |
|
|
229 |
@Override
|
|
230 |
public void run()
|
|
231 |
{
|
|
232 |
while (!up)
|
|
233 |
{
|
|
234 |
try
|
|
235 |
{
|
|
236 |
// wait to see if not a click event
|
|
237 |
Thread.sleep(GuiConstants.REPEAT_MILLIS);
|
|
238 |
|
|
239 |
// fire mouse clicked
|
|
240 |
// call scroll bar
|
|
241 |
|
|
242 |
if (!up)
|
|
243 |
{
|
|
244 |
owner.onButtonClick(position, false);
|
|
245 |
}
|
|
246 |
}
|
|
247 |
catch (InterruptedException ex)
|
|
248 |
{
|
|
249 |
// nop
|
|
250 |
}
|
|
251 |
}
|
|
252 |
}
|
|
253 |
});*/
|
231 |
254 |
}
|
232 |
255 |
}
|
233 |
256 |
|
... | ... | |
244 |
267 |
if (owner.isEnabled())
|
245 |
268 |
{
|
246 |
269 |
up = true;
|
247 |
|
refresh();
|
|
270 |
repaint();
|
|
271 |
// call scroll bar
|
|
272 |
owner.onButtonClick(position, false);
|
248 |
273 |
}
|
249 |
274 |
}
|
250 |
275 |
|