Ruby bind object with function in Shoes

I have 2 edit lines in Ruby Shoes GUI. I need to can perform an addition
only if I press enter and @e_ln1 is in focus. How can I do it? In my
program, even if focus is in @e_ln2 and I press enter, addition is
performed. It’s bad because e.g. I may want to bind press enter while
focus is in @e_ln2, with different action than addition, in future.

Shoes.app do

@e_ln1 = edit_line(width: 150, height: 20)
@e_ln2 = edit_line(width: 150, height: 20, left: 0, top: 60)

keypress do |k|
if k == “\n”
@e_ln1.text = @e_ln1.text.to_i + 1
end
end

end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs