Reputation: 99
How can I call addition only when I press enter and @e_ln1
is in focus? If I click enter while @e_ln2
is in focus, addition in @e_ln1
is also performed but I don't want it.
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
Upvotes: 0
Views: 115
Reputation: 81
in Shoes3.3.1 there is a finish event on edit_line
Shoes.app do
@e_ln1 = edit_line(width: 150, height: 25)
@e_ln2 = edit_line(width: 150, height: 25, left: 0, top: 60)
@e_ln1.finish = proc { @e_ln1.text = @e_ln1.text.to_i + 1 }
end
just hit enter in the edit_line of interest to trigger it
Upvotes: 1
Reputation: 557
This is not possible as far as I'm aware as of now in both Shoes 3 and Shoes 4. In Shoes 4 there's even a bug where we don't get keypresses while there is focus on an input field. Sorry :-/
I don't have Shoes 3 running right now, but you could see and check if the "\n" arrives in the input field and check based on that.
Otherwise I opened a Shoes 4 issue to implement a focussed?
method
Upvotes: 1