Keyboard Input

View: New views
2 Messages — Rating Filter:   Alert me  

Keyboard Input

by Eddy Ilg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have a customly designed canvas widget. On top of the widget I have an
overlay that captures all mouse events.

Now I am trying to add keyboard input, but it just won't work. When the
user clicks on the canvas, I use dijit.focus(..) to focus to the dom
node that represents the overlay div. To the same div I am connecting
the onkeypress event, but I am not receiving keyboard events.

I event tried to connect keypress to dojo.body(). That works, but only
when keys are entered into standard digits. If entered on my canvas,
nothing happens.


Am I missing something here? Is it even possible to connect keyboard
input to div's?


Best regards,




Eddy
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Re: Keyboard Input

by seth lytle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i've just been dealing with some of this. i think that for a div to be
able to receive focus, you need to set tabIndex (positive puts it in
the tab rotation, negative makes it focusable, 0 makes it
unfocusable). then use dojo.connect. i think that dojo.body() should
have worked. if by widget you mean it extends dijit._Widget, i'm not
sure if that changes anything - i haven't written a custom dijit
widget yet. or maybe there's a second handler installed by your widget
that does a dojo.stopEvent ?

i've run into a few problems. i was using dojo.connect( null,
'onclick', ... ) which worked ok on firefox, but if failed on ie - i
guess it uses window as the object, and window.onclick doesn't work on
ie. now i'm using dojo.doc.documentElement - i think dojo.body() was
working too ... don't think i had a reason for switching. and when
using firebug lite, the dojo.body() caught keystrokes to the firebug
command line - so now i ignore them if they're of tagName 'INPUT'

seth/nqzero


On Sat, Nov 7, 2009 at 4:58 PM, Eddy Ilg <me@...> wrote:

> Hi,
>
> I have a customly designed canvas widget. On top of the widget I have an
> overlay that captures all mouse events.
>
> Now I am trying to add keyboard input, but it just won't work. When the
> user clicks on the canvas, I use dijit.focus(..) to focus to the dom
> node that represents the overlay div. To the same div I am connecting
> the onkeypress event, but I am not receiving keyboard events.
>
> I event tried to connect keypress to dojo.body(). That works, but only
> when keys are entered into standard digits. If entered on my canvas,
> nothing happens.
>
>
> Am I missing something here? Is it even possible to connect keyboard
> input to div's?
>
>
> Best regards,
>
>
>
>
> Eddy
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> Dojo-interest@...
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest