I don't think that should be too hard ( just guessing ). On one of our
projects, we are forcing keyboard focus onto our canvas3d when we get
mouse focus, and then we watch for keyboard presses for navigation.
I would set up for AWT keyboard and mouse clicks, and just remember when
the letters you want to watch for are *pressed*. Then, when you get a
mouse click, you will already know if a letter key is being pressed.
Also, watch for keys being *released*. *Pressed/released* events are
different then *typed* events.
... excerpt from the java.awt.event.KeyEvent API page:
For example, pressing the Shift key will cause a KEY_PRESSED event with
a VK_SHIFT keyCode, while pressing the 'a' key will result in a VK_A
keyCode. After the 'a' key is released, a KEY_RELEASED event will be
fired with VK_A. Separately, a KEY_TYPED event with a keyChar value of
'A' is generated.
I'm thinking something like:
During construction...
WakeupOnAWTEvent w1 = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED);
WakeupOnAWTEvent w2 = new WakeupOnAWTEvent(KeyEvent.KEY_RELEASED);
WakeupOnAWTEvent w3 = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
WakeupOnAWTEvent w4 = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);
private WakeupCriterion[] warray = { w1, w2, w3, w4 };
private WakeupCondition w = new WakeupOr(warray);
Somewhere in processStimulus:
if( keyEvent.getKeyCode() == VK_A )
{
key_A_pressed =
(keyEvent.getID() == KeyEvent.KEY_PRESSED );
}
The member variable "key_A_pressed" would let you remember when "a" is
pressed down. Am I glossing over something majorly wrong? Of course
this behavior would wake up whenever any key is pressed ( not just a-z
), but if it's not the key you want then you don't do any major
processing.
-Lee
> -----Original Message-----
> From: Crossley, Allistair [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 22, 2001 6:48 AM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] Chellenge To Java3D Engineers ;)
>
>
> Will you all join me in asking a Java3D engineer(s) to
> demonstrate with code
> how to write a picking behaviour that only wakes up on left
> click whist a
> character key "A-Z" is depressed.
>
> All the examples with Java3D are with Alt or Control but
> these are useless
> for big applications except for zoom and translate. Besides, there are
> special functions in the events classes that can detect these
> being down at
> the time of the click too which makes these easier.
>
> Anyone in favour of a concrete example from the makers of J3D
> say "Aye".
>
> Cheers,
>
> Allistair Crossley
> Web/New Media Consultant
> Logica UK Ltd
> Tel: 02074 463267
> Mob: 07884 056274
>
> -----Original Message-----
> From: Karsten Fries [mailto:[EMAIL PROTECTED]]
> Sent: 22 May 2001 09:24
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] Mouse events
>
>
> Hi there,
>
> another mouse question.
> I have the problem that I use left mouse click for selecting
> objects and
> left mouse double-click for zooming
> in. In big complex scenes the picking stuff is very computation
> intensive and therefore takes a while (in the range of a second is
> the max we can tolerate), but anyway the double click is not
> produced if
> it takes too long.
>
> Rephrased: if i double-click on a complex object (say build of 30000
> triangles) I get two mouse click events with
> clickCount() == 1 instead of one with cC==1 and a secong with cC == 2.
>
> Pitty!!
>
>
> Is there any way of getting around this. I already rearranged
> the mouse
> controls, but I'm always running in some
> problems concering this issue.
>
> Any help is appreciated!!
>
> Thanks and 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".
>
> ==============================================================
> =============
> 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".
>
===========================================================================
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".