As far as I know, if all I wanted to do was do "puts" in a console, then I would not be having to ask this question. (However, finally I am asking you all at StackOverflow myself, though I've been visiting for years.)
Here is my issue:
- I am trying to create a variable which will be "set" to a specific value upon user click
- I am then trying to display that value after it is changed
- I can set the value, but it does not get displayed
(Of course, this should work if I am not using Shoes.)
Here is the relevant portion of my code:
class Inits
# Declares all global vars used
def init1
...
end
def initattrib
@id = "###"
@name = "name undef"
alert("Alert: default attrib set")
end
def id
@id
#alert("Alert: id call")
end
def name
@name
#alert("Alert: name call")
end
def id=(newid)
@id = newid
#alert("Alert: id set")
end
def name=(newname)
@name = newname
#alert("Alert: name set")
end
end
Then I am trying to call the id and set it as so:
Shoes.app :width => 800, :height => 600, :resizable => false do
currclass = Inits.new
currclass.init1
currclass.initattrib
.
.
.
id = "123"
name = "new name"
# I declare something to click here
click { currclass.id = id, currclass.name = name }
# Then I try to display it as so:
para currclass.id
para currclass.name
# But of course the value is not displayed -- just the default value
end
... As an aside, I am pretty sure I should be using instance variables and not class variables (@x, not @@x).
Is there some way I can "update on change" ("clock rising edge" is a good analogy) or some other way to call this?
Anyhow, thank you in advance for any advice on what I am not doing correctly. Perhaps there is a misunderstanding.
If I understood correctly what you want to do you should do it like that:
K