Can we not get keypress events from input elements? That's rather annoying. In building html apps, the keyup event particularly is very useful for constricting the kinds of characters that can go in the input and doing other magic stuff. keydown is useful for stuff like handling the return key and making stuff happen. If they aren't already there, a keydown and change event (that works when a change happens, not like html.. so any time anything happens, be it a paste, a key press, whatever) would be really nice to have on the form elements. :)

On 27/06/2008, at 12:10 AM, _why wrote:

On Thu, Jun 26, 2008 at 12:51:08AM -0400, Tieg Zaharia wrote:
I was wondering why it's not possible to call animate() inside a keypress event? All the typical Shoes shapes seem to work in one, but if you nest an
animate() loop in there it doesn't work.

Is animate() mostly intended to encompass whole apps, or is it possible to
do little animate() parts only when we need them?

What platform are you on?  animate() should be okay in a keypress().

Here's an example that will move a circle when you press a key.  And
then pause it the next time you press a key.

 Shoes.app do
   background white
   @circle = oval 0, 0, 100, 100

   keypress do
     if @anim
       @anim.toggle
     else
       @anim = animate do |i|
         @circle.move i, i
       end
     end
   end
 end

One thing you have to remember about using `animate` in a keypress
or mouse event is that it'll create a new animation loop every time
the event goes off.  Jenna's advice of starting the animation
outside the event is good.

It's also possible that your keypress isn't going off due to a form
element.

_why

Reply via email to