Following the Tweets example of Teacup, I'm trying to access a variable outside of the layout block
class WindowController < TeacupWindowController
stylesheet :pref_window
layout do
@loginButton = subview(
NSButton, :loginButton,
state: NSOffState,
buttonType: NSSwitchButton,
action: 'login',
target: self,
)
puts @loginButton.class
end
puts @loginButton.class
the first puts returns NSButton class, but the second one returns Nil class.
how can I access @loginButton if I need to programmatically make changes to it?
For example:
@loginButton.setState(NSOnState)
doesn't work outside the layout block.