I assume you meant faking the pressing of a key on the keyboard.

You can't do that directly, no, but you can sort-of call the
keylisteners on any particular object.

For example, let's say you have a TextBox instance called 'textBox',
and you want to simulate pressing the 'X' button.

You'll need to do two things:

1) Simulate the effect of the X button on the textBox itself, which
means updating the text inside by inserting an X at the current cursor
position.

2) Call all keyboardlisteners on textBox.

#2 can be done with some technically nonsupported hackery - each
implementation of SourcesKeyboardEvents in GWT at least has an
internal private object of type 'KeyboardListeners', called
'keyboardListeners'. While its private, you can still get at it via
JSNI (look that up) which doesn't know about 'private' and thus allows
it. Once you have the keyboardListeners, which is really just an
ArrayList, you can loop through them and fire the appropriate call
(e.g. onKeyPress) on all of them.


The reason GWT doesn't support this directly is because javascript
doesn't support it either. GWT isn't magic; it cannot make things that
are impossible on the target platform possible.

On Jan 2, 2:26 pm, Anurag Tripathi <anurag...@gmail.com> wrote:
> Can we programmatically generate physical keys in GWT ?
>
> Scenario : I want to generate some key on clicking in Button !
>
> If anyone has any idea on this, please let me know -
>
> _Anurag
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to