That work perfectly. What a silly mistake!!! Of course it should have been position := aPoint. Now, is it possible write the drawOn: method without calling super drawOn: a Canvas? I don't completely get it why I should call super drawOn: aCanvas thanks nacho
*Lic. Ignacio Sniechowski, MBA* *Prosavic SRL* *Tel: (011) 4542-6714* On Thu, Feb 5, 2015 at 11:28 AM, Trygve Reenskaug [via Smalltalk] < ml-node+s1294792n4803964...@n4.nabble.com> wrote: > I've tested your code in Squeak and found another bug (I should have been > more careful when I read your code. Shame on me.) > > In class Ball you have the methods > > position: aPoint > super position: aPoint. > This does not set a value to your position variable in class Ball, but > actually sets the upper-left corner of the bounds. > You should have said position := aPoint. > -------------------------------- > The following now works in mySqueak image: > EllipseMorph subclass: #Ball > instanceVariableNames: 'position' > classVariableNames: '' > poolDictionaries: '' "this part is needed in Squeak" > category: 'ZZZtesting' > > drawOn: aCanvas > self borderWidth:10; borderColor: Color green. > super drawOn: aCanvas. > > position > ^ position. > > position: aPoint > position := aPoint. > > > I then execute the following in a workspace > | aBall | > aBall := Ball new. > aBall position: ( 10@10 ). > aBall openInWorld. > > and it seems to work. But closer scrutiny shows that it ignores your > instance variable (position). when I move the ball around. > The reason is that EllipseMorph is a superclass of your Ball and cannot > possibly know about an instance variable (position) that is defined in the > subclass (Ball). > > I ignored Ball>position since the EllipseMorph doesn't use it: > > EllipseMorph subclass: #Ball > instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'ZZZtesting' > > position > ^ super position. > > position: aPoint > super position: aPoint. > This looks better. > I you really want to replace the EllipseMorph>position you must go deeper > into how the EllipseMorph handles its position and bounds . This will not > be trivial. Much easier to invent a new instance variable and use it in the > drawOn: method. > > Good luck with your apprenticeship > > > > > > > > > > On 05.02.2015 11:56, nacho wrote: > > @Trygve > I've checked and it doesn't work. I can't even bring the halo on to delete > the morph. The debugger keeps popping. > Thanks anyway to all > Nacho > > > > > ----- > Nacho > Smalltalker apprentice. > Buenos Aires, Argentina. > -- > View this message in context: > http://forum.world.st/Question-on-Morphic-drawOn-method-tp4803695p4803895.html > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com. > > > > > > -- > > *The essence of object orientation is that objects collaborate to achieve > a goal. * > Trygve Reenskaug [hidden email] > <http:///user/SendEmail.jtp?type=node&node=4803964&i=0> > Morgedalsvn. 5A http://folk.uio.no/trygver/ > N-0378 Oslo http://fullOO.info > Norway Tel: (+47) 22 49 57 27 > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://forum.world.st/Question-on-Morphic-drawOn-method-tp4803695p4803964.html > To unsubscribe from Question on Morphic drawOn: method., click here > <http://forum.world.st/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4803695&code=MDgwMG5hY2hvQGdtYWlsLmNvbXw0ODAzNjk1fC0xOTAxMTExODEy> > . > NAML > <http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > ----- Nacho Smalltalker apprentice. Buenos Aires, Argentina. -- View this message in context: http://forum.world.st/Question-on-Morphic-drawOn-method-tp4803695p4803979.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.