PDA

View Full Version : Dashboard Widget Question




atari1356
Nov 22, 2004, 06:41 PM
A simple question for anybody who has Tiger:

With the Calculator widget Apple currently has in Tiger, can you use the number keypad on your keyboard to enter information? Or do you have to use the mouse and click on each number? Since the widgets are built using html/css/javascript I'm not sure if that's possible.

I'm curious because I'm trying to develop my own calculator app, and am debating on whether to make it a Widget - or full blown Cocoa app.

Thanks :)



robbieduncan
Nov 23, 2004, 08:47 AM
Not at home to try it out for you, but it is perfectly possible to capture keyboard events in JavaScript. Take a look at Chapter 19 of "JavaScript The Definitive Guide" if you have a copy.

Take a look at the onkeypress (or onkeydown) handlers for the body tag.

ang8385
Nov 23, 2004, 08:57 AM
yes it can, but first you'll have to click once on the calculator :)

atari1356
Nov 23, 2004, 03:44 PM
Not at home to try it out for you, but it is perfectly possible to capture keyboard events in JavaScript. Take a look at Chapter 19 of "JavaScript The Definitive Guide" if you have a copy.

Take a look at the onkeypress (or onkeydown) handlers for the body tag.

Thanks, I don't have that book but I'll see if I can find out how to do that elsewhere. :)

robbieduncan
Nov 23, 2004, 04:57 PM
Thanks, I don't have that book but I'll see if I can find out how to do that elsewhere. :)

Fair enough! It was sitting on my desk at work, so handy. Give this (http://www.devguru.com/Technologies/ecmascript/quickref/evhan_onKeyPress.html) a shot...