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.