Hiya
I have tried another tutorial but lost. I have done exactly but I'll explain after the code. Its a bit long so here goes. I create a subclass of ShellView. That works fine. This is where it goes I have to creat a method called onPaintRequired for the subclass Greeting. onPaintRequired: aPaintEvent "A portion of the receiver window has been exposed and needs repainting. The supplied aPaintEvent holds details about the exposed area. Within #onPaintRequired: you MUST ask for a canvas from aPaintEvent (not the receiver window) to paint the contents on" | canvas | canvas := aPaintEvent canvas. canvas pen: Pen red; brush: Brush gray; ellipse: (Rectangle origin: 0@0 extent: 250@150); text: 'Hello from Dolphin' at: 50@50 This accepts the code. then we have to create a onPostionChanged method. Is this created in the subclass Greeting? What I mean is when you Accept the code do you just go to Method New and type away (next bit coming)? onPositionChanged: aPositionEvent "The receiver has been positioned or resized. Force a repaint of the entire client area. We need to do this in cases where changing the extent of a View alters the way in which it is painted (rather than just the area that is repainted)" self invalidate ^super onPositionChanged: aPositionEvent We then modify the #onPaintRequired..(does # mean method)? same thing in "'s then | canvas box textbox | box := self clientRectangle. canvas := aPaintEvent canvas canvas pen: Pen red; brush: Brush gray; ellipse: box; font: (Font name: 'Arial' pointSize: 24); setTextAlign: TA_CENTER | TA_BASELINE; setBkMode:TRANSPARENT; setTextColor: Color red; text: 'Hello from Dolphin' at: box center. Thia Accepts. Now, as I say, is the onPositionChanged method supposed to be put in the Subclass Greeting from the class ShellView directly after I type in the first method (onPaintRequired)? I just finished the first one, went to Accept then went to Method - New and entered the second method. Anyway, I finished all this and it accepted. Then I try and evaluate w := Greeting new show and it comes up with the debugger and quite a lot of the pop ups are to do with pointSize. closed as many as possible but then it freezes. Any ideas? I have just started so a very newbie but would be grateful for any replies. Sorry for the long post. Thank you in advance Eddie Sent via Deja.com http://www.deja.com/ |
Eddie,
[..] > then we have to create a onPostionChanged method. Is this created in > the subclass Greeting? What I mean is when you Accept the code do you > just go to Method New and type away (next bit coming)? Yes and Yes. After accepting you can omit the Method/New bit and just overwrite any text in the edit field. As long as you put a new selector (method name) at the start of the text the compiler will know what you want to do when you accept the next lot of text. > self invalidate > ^super onPositionChanged: aPositionEvent Full stop missing after the 'invalidate'. > We then modify the #onPaintRequired..(does # mean method)? In Dolphin (the language) it indicates a Symbol but in the context of an article like this it does usually indicate a method selector (the method's name). The >> notation is also used, in documentation or text, to also indicate the class where the method is defined so Greeting>>onPositionChanged: is the full description of the above method. > | canvas box textbox | > box := self clientRectangle. > canvas := aPaintEvent canvas > canvas > pen: Pen red; [..] Full stop needed after canvas in "canvas := aPaintEvent canvas" > Now, as I say, is the onPositionChanged method supposed to be put in > the Subclass Greeting from the class ShellView directly after I type in > the first method (onPaintRequired)? I just finished the first one, went > to Accept then went to Method - New and entered the second method. If you are going to immediately overwrite the first #onPaintRequired: then there is no need to enter it before entering the second #onPaintRequired:. I imagine the idea of the tutorial was to enter the first #onPaintRequired and #onPositionChanged:, try it out by "Greeting new show" and then edit #onPaintRequired to see how it affects the output. Adding a new method with the same name as an existing one completely overwrites the current one, as if it never existed. > Anyway, I finished all this and it accepted. Then I try and evaluate > > w := Greeting new show > > and it comes up with the debugger and quite a lot of the pop ups are to > do with pointSize. closed as many as possible but then it freezes. I cut and pasted the above into Dolphin 2.1 (is that what you are using)? and it works correctly for me (after adding the two missing full stops). Is the text you posted the actual text copied from the browser.? > Any ideas? I have just started so a very newbie but would be grateful > for any replies. Sorry for the long post. Check through for typos, or copy the text from your post, and try again. If it still doesn't work then post the text from the walkback window [1] for the _first_ error that appears. <insert>Standard 'Smalltalk is hard work at the start but worth it in the end' speech</insert> Ian [1] The easy way. When you get the walkback (the initial grey box that indicates an error has occurred) point at the error list and right click. Choose "Select All" then "Copy" from the context menu and then paste the clipboard contents back into the reply. |
Thanks Ian. I put the full stops in but it still does it. The window
that pops up has the oval and is grey but then the good old walkbak is there. Here it is as requested. Font class(Object)>>doesNotUnderstand: Greeting>>onPaintRequired: [] in Greeting(View)>>wmPaint:wParam:lParam: ExceptionHandler(ExceptionHandlerAbstract)>>markAndTry [] in ExceptionHandler(ExceptionHandlerAbstract)>>try: BlockClosure>>ensure: ExceptionHandler(ExceptionHandlerAbstract)>>try: BlockClosure>>on:do: Greeting(View)>>wmPaint:wParam:lParam: Greeting(View)>>dispatchMessage:wParam:lParam: [] in InputState>>wndProc:message:wParam:lParam: BlockClosure>>ifCurtailed: ProcessorScheduler>>callbackEvaluate: InputState>>wndProc:message:wParam:lParam: InputState>>pumpMessage: InputState>>loopWhile: InputState>>mainLoop [] in InputState>>forkMain ExceptionHandler(ExceptionHandlerAbstract)>>markAndTry [] in ExceptionHandler(ExceptionHandlerAbstract)>>try: BlockClosure>>ensure: ExceptionHandler(ExceptionHandlerAbstract)>>try: BlockClosure>>on:do: [] in BlockClosure>>newProcess Regards Eddie Yes, I am using 2.1 In article <9492b4$1l3$[hidden email]>, "Ian Bartholomew" <[hidden email]> wrote: > Eddie, > > [..] > > then we have to create a onPostionChanged method. Is this created in > > the subclass Greeting? What I mean is when you Accept the code do you > > just go to Method New and type away (next bit coming)? > > Yes and Yes. After accepting you can omit the Method/New bit and just > overwrite any text in the edit field. As long as you put a new selector > (method name) at the start of the text the compiler will know what you want > to do when you accept the next lot of text. > > > self invalidate > > ^super onPositionChanged: aPositionEvent > > Full stop missing after the 'invalidate'. > > > We then modify the #onPaintRequired..(does # mean method)? > > In Dolphin (the language) it indicates a Symbol but in the context of > article like this it does usually indicate a method selector (the method's > name). The >> notation is also used, in documentation or text, to also > indicate the class where the method is defined so > Greeting>>onPositionChanged: is the full description of the above method. > > > | canvas box textbox | > > box := self clientRectangle. > > canvas := aPaintEvent canvas > > canvas > > pen: Pen red; > [..] > > Full stop needed after canvas in "canvas := aPaintEvent canvas" > > > Now, as I say, is the onPositionChanged method supposed to be put in > > the Subclass Greeting from the class ShellView directly after I > > the first method (onPaintRequired)? I just finished the first one, went > > to Accept then went to Method - New and entered the second method. > > If you are going to immediately overwrite the first #onPaintRequired: then > there is no need to enter it before entering the second #onPaintRequired:. I > imagine the idea of the tutorial was to enter the first #onPaintRequired and > #onPositionChanged:, try it out by "Greeting new show" and then edit > #onPaintRequired to see how it affects the output. Adding a new method > with the same name as an existing one completely overwrites the current one, > as if it never existed. > > > Anyway, I finished all this and it accepted. Then I try and evaluate > > > > w := Greeting new show > > > > and it comes up with the debugger and quite a lot of the pop ups are to > > do with pointSize. closed as many as possible but then it freezes. > > I cut and pasted the above into Dolphin 2.1 (is that what you are using)? > and it works correctly for me (after adding the two missing full stops). Is > the text you posted the actual text copied from the browser.? > > > Any ideas? I have just started so a very newbie but would be grateful > > for any replies. Sorry for the long post. > > Check through for typos, or copy the text from your post, and try again. If > it still doesn't work then post the text from the walkback window [1] for > the _first_ error that appears. > > <insert>Standard 'Smalltalk is hard work at the start but worth it in the > end' speech</insert> > > Ian > > [1] The easy way. When you get the walkback (the initial grey box that > indicates an error has occurred) point at the error list and right click. > Choose "Select All" then "Copy" from the context menu and then paste the > clipboard contents back into the reply. > > Sent via Deja.com http://www.deja.com/ |
Eddie,
> Font class(Object)>>doesNotUnderstand: > Greeting>>onPaintRequired: I should have asked for the actual contents of the walkback window caption as well but it looks like the line in #onPaintRequested: that reads font: (Font name: 'Arial' pointSize: 24); is wrong, specifically the "name:" or "pointSize:" bits are spelt wrong/capitalized incorrectly. The wording of the walkback caption should show the error as it will show something different to the expected #name:pointSize: One other alternative is that you have accidentally deleted a method from the Font class. Using the class browser navigate to the Font class, select the "class" tab in the central view and look for a method named #name:pointSize: If it's missing that will also cause the error. If this is the case you should start again with a clean image as you don't know what else has been deleted. doesNotUnderstand is a very common error and means that the object that is receiving a selector does not understand what to do with it as there is no corresponding method defined in it's class or superclass. Usually caused by spelling mistakes in either the sending or receiving selector or as part of the development process when testing a partially completed class. Ian |
Ian
This is a bit of a strange reply as I haven't been home this weekend. Been at York on a course. Anyway, whilst I was there bored out of my skull I had a little think. Could this be the answer? font: (FontName: 'Arial' PointSize: 24); I thought that as you put ShellView that you might also put FontName. Later tonight I will try those things that you have written here ( at work now) and I thought I might look for the FontName and PointSize under the ShellView class. I assume that they should be there somewhere. Regards Eddie In article <94a5lc$d215s$[hidden email]>, "Ian Bartholomew" <[hidden email]> wrote: > Eddie, > > > Font class(Object)>>doesNotUnderstand: > > Greeting>>onPaintRequired: > > I should have asked for the actual contents of the walkback window caption > as well but it looks like the line in #onPaintRequested: that reads > > font: (Font name: 'Arial' pointSize: 24); > > is wrong, specifically the "name:" or "pointSize:" bits are spelt > wrong/capitalized incorrectly. The wording of the walkback caption should > show the error as it will show something different to the expected > #name:pointSize: > > One other alternative is that you have accidentally deleted a method from > the Font class. Using the class browser navigate to the Font class, select > the "class" tab in the central view and look for a method named > #name:pointSize: If it's missing that will also cause the error. If this is > the case you should start again with a clean image as you don't know what > else has been deleted. > > doesNotUnderstand is a very common error and means that the object that is > receiving a selector does not understand what to do with it as there is no > corresponding method defined in it's class or superclass. Usually caused by > spelling mistakes in either the sending or receiving selector or as part of > the development process when testing a partially completed class. > > Ian > > Sent via Deja.com http://www.deja.com/ |
Eddie,
> This is a bit of a strange reply as I haven't been home this weekend. > Been at York on a course. Anyway, whilst I was there bored out of my > skull Heh. I've been on a few courses like that > I had a little think. Could this be the answer? > > font: (FontName: 'Arial' PointSize: 24); No. Although the problem is almost certainly spelling/capitalisation that would definitely be wrong. The name of the class is Font. This must start with a capital letter or it wouldn't have got past the compiler when the class was created. There must be a space after the class name and before the selector of the message being sent to the Font class. The selector for the method #name:pointSize: Methods selectors normally, although not compulsorily, start with a lowercase letter. Each part of a multiple keyword selector (pointSize:) will also (usually) start with a lowercase letter The complete expression works in two parts Font name: 'Arial' pointSize: 24 sends the #name:pointSize: message to the Font class with two arguments ('Arial' and 24). The Font class answers a new Font instance. canvas ..... font: (aNewFontInstance) sends the #font: message to the canvas object (an instance of the Canvas class in this case) passing the new font that was created above as an argument. > I thought that as you put ShellView that you might also put FontName. ShellView is the name of a class. The capital V is just an aid, splitting the class name up to make it more readable. You could rename the class to Shellview without making any difference to the code although you would have to edit all the references to ShellView to mirror the change. Font and Name are two different things, a class name and a selector, and should be separated. Ian |
Free forum by Nabble | Edit this page |