You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Andrew Plotkin <za...@volity.com> on 2006/07/07 05:30:40 UTC
Double click events in Batik
For months, my Windows users have reported an occasional problem: the user
clicks the mouse once, but sees two click events. (This is on a simple SVG
object, like a rectangle, with an onclick="func()" attribute. The func()
function runs twice.)
After grepping furiously through the source, I find this code in
swing/gvt/AbstractJGVTComponent.java, and it seems to be the source of the
problem:
public void mouseReleased(java.awt.event.MouseEvent e) {
if ((checkClick) && hadDrag) {
int dx = startX-e.getX();
int dy = startY-e.getY();
long cTime = System.currentTimeMillis();
if ((dx*dx+dy*dy < MAX_DISP) &&
(cTime-startTime) < CLICK_TIME) {
// our drag was short! dispatch a CLICK event.
//
MouseEvent click = new MouseEvent
(e.getComponent(),
MouseEvent.MOUSE_CLICKED,
e.getWhen(),
e.getModifiers(), // modifiers
e.getX(),
e.getY(),
e.getClickCount(),
e.isPopupTrigger());
mouseClicked(click);
}
}
checkClick = false;
hadDrag = false;
Originally I thought this was the source of the standard "down+up ->
click" mouse events. But it's not. This code only fires when hadDrag is
true, which occurs when a mouseDragged event shows up.
So if the user clicks the mouse and releases it, this code does *not* run;
a MOUSE_CLICKED event occurs from some other piece of code. But if the
user clicks the mouse, moves it *just a little* (less than MAX_DISP) and
quickly (faster than CLICK_TIME), then this code *does* run -- but the
other click event occurs anyway. So the document sees two onclick events,
and then I get a bug report, and then I weep.
This only seems to happen on Windows. On the Mac, if this bit of code
runs, then the other click event *doesn't* occur. At least, that's what I
see -- I never notice two events coming from the same click.
This code seems to exist in order to tolerate very slight mouse movements
during a click. That's fine, but the value of that is crushed by the
possibility of duplicate events.
(In case it matters: I compiled Batik on the Mac with Java 1.5.0_06-64.
The Windows box I'm testing with has Java 1.5.0_06-b05.)
--Z
--
Andrew Plotkin zarf@volity.com Volity Games
*
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Double click events in Batik
Posted by Andrew Plotkin <er...@eblong.com>.
On Fri, 7 Jul 2006, thomas.deweese@kodak.com wrote:
> Hi Andrew,
>
> I just committed the fix this morning...
Yes, I'm sorry. My mail got delayed slightly, so our messages crossed.
I tried the change you checked in, and it works perfectly. Thank you.
--Z
--
Andrew Plotkin zarf@volity.com Volity Games
*
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Double click events in Batik
Posted by th...@kodak.com.
Hi Andrew,
I just committed the fix this morning...
Andrew Plotkin <za...@volity.com> wrote on 07/07/2006 09:59:10 AM:
> On Thu, 6 Jul 2006, Andrew Plotkin wrote:
>
> > This code seems to exist in order to tolerate very slight mouse
movements
> > during a click. That's fine, but the value of that is crushed by the
> > possibility of duplicate events.
> >
> > (In case it matters: I compiled Batik on the Mac with Java
1.5.0_06-64. The
> > Windows box I'm testing with has Java 1.5.0_06-b05.)
>
> And, let me add, my snapshot of SVN is a few months old. There haven't
> been any changes to this file (except an error type declaration
somewhere)
> but it's possible that a change elsewhere in Batik has fixed the bug. If
> so, just tell me. :)
>
> --Z
>
> --
> Andrew Plotkin zarf@volity.com Volity
Games
> *
> "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
borogoves..."
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Double click events in Batik
Posted by Andrew Plotkin <za...@volity.com>.
On Thu, 6 Jul 2006, Andrew Plotkin wrote:
> This code seems to exist in order to tolerate very slight mouse movements
> during a click. That's fine, but the value of that is crushed by the
> possibility of duplicate events.
>
> (In case it matters: I compiled Batik on the Mac with Java 1.5.0_06-64. The
> Windows box I'm testing with has Java 1.5.0_06-b05.)
And, let me add, my snapshot of SVN is a few months old. There haven't
been any changes to this file (except an error type declaration somewhere)
but it's possible that a change elsewhere in Batik has fixed the bug. If
so, just tell me. :)
--Z
--
Andrew Plotkin zarf@volity.com Volity Games
*
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Double click events in Batik
Posted by th...@kodak.com.
Hi Andrew,
Andrew Plotkin <za...@volity.com> wrote on 07/06/2006 11:30:40 PM:
> For months, my Windows users have reported an occasional problem: the
user
> clicks the mouse once, but sees two click events. (This is on a simple
SVG
> object, like a rectangle, with an onclick="func()" attribute. The func()
> function runs twice.)
This should be fixed in SVN now.
> This code seems to exist in order to tolerate very slight mouse
movements
> during a click. That's fine, but the value of that is crushed by the
> possibility of duplicate events.
It now suppresses the 'system' click if the timestamp matches
the mouseRelease time stamp of the 'fake' click we provide.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org