Hi Timothy and Cecil,

That is a known problem. Look at the below post and lots of discussions.

- Edit_line and keypress
http://www.mail-archive.com/[email protected]/msg03769.html

If you want to use enter-key, this might also be useful.

- Gallery 2-1
http://shoes-tutorial-note.heroku.com/html/01110_Fancy_Gallery_1-5.html

Regards,
Satoshi


On Sun, Jul 12, 2009 at 2:25 PM, Cecil Coupe <[email protected]> wrote:

> Hi,
>  This may not help, but what I've done is something like this to enter
> a string
>
>  @el = edit_line @outMB, :width => 40 do
>        @outMB = @el.text
>        # call your function here
>  end
>
> Attach the block to the edit_line and don't worry about keypress
> (unless you really need key by key actions)
>
> On Sat, 2009-07-11 at 22:23 -0600, Timothy McDowell wrote:
> > ef roll die
> >   a = nil
> >   if (a = die.match(/([0-9]+)d([0-9]+)/))
> >     answer = 0
> >     a[1].to_i.times do
> >       answer += rand(a[2].to_i) + 1
> >     end
> >     return answer
> >   else
> >    para "Not a valid die type."
> >   end
> > end
> >
> >
> > Shoes.app do
> >   @text = para "Type a die roll into the box, and then hit enter. Ie:
> > 2d6"
> >   flow do
> >     @editline = edit_line
> >   end
> >   keypress do |k|
> >     case k
> >       when :enter
> >         a = roll @editline.text
> >         para a.to_s
> >         @text.replace a
> >     end
> >   end
> > end
> >
> >
> > There is my code. I know my 'roll' method works fine. When I hit
> > 'enter' when the editline has focus, nothing happens... any help?
> >
> > --
> > --Brains.
>
>

Reply via email to