instance variables need to get updated.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

instance variables need to get updated.

kanmani priyadharshini
Hi,
 
I am Priya. I am entirely new to Pharo. I have to submit a project in one week to get placed (tough task for those who dont have any knowledge about smalltalk or the Pharo environment).
 
I am doing a very small project for getting two numbers from the user and performing basic
calculations on them. There is a drop-down menu with options - add, subract, multiply,
divide.
 
I have a problem with this step.
content := (builder newLabelGroup: {
                'First number' -> (
                       n1 := (builder
                         newTextEntryFor:self
                         getText: #num1
                         setText:  #num1:    
                         help: 'Enter the first number')
                         acceptOnCR: false;
                         minWidth: 200).  .......
Here, num1 is an instance variable with accessors (returns 0 as default). num1 is not
getting upated when I enter in the text field. I am not getting any error also. Transcript
window is showing the value of num1 as 0. Can anyone help me with this, please?
 
(Event handling and all is working properly sending a message to the add method. Only the instance variables are not getting updated.)
Reply | Threaded
Open this post in threaded view
|

Re: instance variables need to get updated.

Sean P. DeNigris
Administrator
kanmani priyadharshini wrote
I am Priya. I am entirely new to Pharo.
Welcome to our community!

kanmani priyadharshini wrote
num1 is an instance variable with accessors (returns 0 as default). num1 is not getting upated when I enter in the text field
In the setter, you have to call "self changed: #num1.". Otherwise the Morph would have to continuously poll to find out if it changed. I always forget this too. When something's not working, I go back and watch http://www.pharocasts.com/2011/02/pharo-gui-with-polymorph.html.

HTH,
Sean
Cheers,
Sean