I have an odd workaround but it may lead you in the right direction.
I used the picking behaviors as a model and created two new behaviors, one
for selecting an object using the pickingcallback method and the other to
fire off a dialog box when someone doubleclicks. The double click method
also using the pickingcallback.
Since I didn't care if the single click behavior got triggered when someone
doubleclicks for the dialog box, this may be slightly different for you.
If you look at the pickrotation behavior and compare this method with the
one in it you will see where I added some code. This fragment is from the
single click behavior:
public void updateScene(int xpos, int ypos)
{
TransformGroup tg = null;
if (!mevent.isMetaDown() && !mevent.isAltDown())
{
tg
=(TransformGroup)pickScene.pickNode(pickScene.pickClosest(xpos, ypos,
pickMode), PickObject.TRANSFORM_GROUP);
// Make sure the selection exists and is movable.
if ((tg != null) &&
(tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) &&
(tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE)))
{
// drag.setTransformGroup(tg);
drag.wakeup();
currentTG = tg;
// Eric is adding
if (callback!=null)
{
callback.transformClicked(
PickingCallback.SELECTION, currentTG);
}
}
else if (callback!=null)
{
callback.transformClicked(
PickingCallback.NO_PICK, null );
}
}
}
Now look at the same code for the doubleclick behavior:
public void updateScene(int xpos, int ypos)
{
TransformGroup tg = null;
if (!mevent.isMetaDown() && !mevent.isAltDown())
{
tg
=(TransformGroup)pickScene.pickNode(pickScene.pickClosest(xpos, ypos,
pickMode),
PickObject.TRANSFORM_GROUP);
// Make sure the selection exists and is movable.
if ((tg != null) &&
(tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) &&
(tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE)))
{
// drag.setTransformGroup(tg);
drag.wakeup();
currentTG = tg;
// Eric is adding
if (callback!=null)
{
if ( mevent.getClickCount() == 2 )
{
callback.transformDoubleClicked(
PickingCallback.PROPERTIES, currentTG);
}
}
}
else if (callback!=null)
{
callback.transformDoubleClicked(
PickingCallback.NO_PICK, null );
}
}
}
Specifically, do you see the line:
if ( mevent.getClickCount() == 2 )
This allowed me to only call the transformDoubleClicked callback method if
the mouse was double clicked.
The key is the .getClickCount() method of the mouse event. It you had a
line like:
if ( mevent.getClickCount() == 1 )
it may allow you to distinguish between single and double clicks.
I never tried it since I didn't care if the behavior caused by a single
click happened when i doubleclicked.
If you have to modify any sun code to make the changes, i suggest you copy
the sources off under another class and make them your own and part of you
application if you plan to distribute you app to other Java3D users.
At 07:12 PM 05/16/2001 +0200, you wrote:
>hi there,
>
>i have two behaviors, one reacting on a mouse click, the other one
>reacting on mouse double-click.
>
>if the user double-clicks the canvas both behaviors are triggered.
>why???
>is there a possibility to get around this?
>how is this actually specified in the AWT? i suppose, a double-click
>comes wothout a preceeding click??
>i really hope so!!!
>
>cheers,
>karsten
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
***********************************************************************
Eric N. Reiss
MEMS Manager
Swanson Center for Product Innovation
Department of Mechanical Engineering
School of Engineering - University of Pittsburgh
3700 O'Hara Street
647 Benedum Hall
Pittsburgh, Pennsylvania 15261
Phone: 412-624-9696
FAX: 412-624-7701
Email: [EMAIL PROTECTED]
http://www.sigda.acm.org/Eric/
***********************************************************************
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".