nXIII wrote:
You mean imageForm?
Or do you want to just draw it on a canvas?
Or do you want to get its current costume form?
imageForm worked. Thanks!
Now how do I make it report an image instead of Form(aXbXc)?
Offline
nXIII wrote:
It IS reporting an image, the tooltip is just using printString on it,
How can I make the tooltip show the image?
Offline
nXIII wrote:
use imageForm in contents:.
How do I do it and where?
Offline
Hi Billybob-Mario,
in the BYOB source code you can just pass a Form (bitmap) - or if I'm not mistaken - even a Morph the the tool tip as "messageString", and it works, even if it's not a String. Just try it. Oh, I might have mentioned this before - it's soooo gratifying to just browse the code....
Offline
The code that I think I need to change is
message: aString
| str |
(aString isKindOf: Form)
ifTrue: [message _ ImageMorph new form: aString ]
ifFalse: [
str _ aString.
(aString isKindOf: String) ifFalse: [
str _ aString printString].
message _ StringMorph
contents: str
font: self messageFont ].
self addMorph: message.
self extent: message extent + (12@3).
message position: 6@1.Offline
Jens wrote:
You don't need to change it, just use it, pass it a Form ("myCustomMorph imageForm") as message argument!
Where do I do that? And what tells a ToolTip to show up in the first place?
Last edited by Billybob-Mario (2010-09-13 06:56:23)
Offline
Just use a Browser! It's how I learned every single thing I know about Squeak. Open a browser and just look around, or you can type the name of a class and hit Alt+B, or even right-click and select "explain" if you're stuck.
Offline
Well, I found this: (ReporterBlockMorph's toggleProcess)
toggleProcess
| toolTip |
toolTip _ self valueOfProperty: #toolTip.
toolTip ifNotNil: [
toolTip delete.
self setProperty: #toolTip toValue: nil.
^ self].
self showValue.Do I do something to this. (It took forever to find, so don't say I didn't do anything.)
Offline
Well, I really agree with nXIII. Smalltalk is a system that completely explains itself once you're familiar with the basic syntax, which by now you absolutely are! Just try stuff and read the code and the comments. Also, look for other situations that already do sort of what you're trying to accomplish and read that code to find out more about how it can be done.
In the case of tooltips there is this wonderful feature (actually it's become my absolute favorite feature of Scratch) that shows the result of calling a reporter in a little speech-bubble shaped tooltip if you double-click on it .... (nudge, nudge, hint, hint ...)
Last edited by Jens (2010-09-13 20:27:45)
Offline
Jens wrote:
Well, I really agree with nXIII. Smalltalk is a system that completely explains itself once you're familiar with the basic syntax, which by now you absolutely are! Just try stuff and read the code and the comments. Also, look for other situations that already do sort of what you're trying to accomplish and read that code to find out more about how it can be done.
In the case of tooltips there is this wonderful feature (actually it's become my absolute favorite feature of Scratch) that shows the result of calling a reporter in a little speech-bubble shaped tooltip if you double-click on it .... (nudge, nudge, hint, hint ...)![]()
The problem is that I don't know where to look. I've looked at tooltips and the hierarchy of ReporterBlockMorph and found the two things that I posted above, but I don't know what to change, even if I find it.
Offline
How would you do it in Scratch? Decide what should happen and when - identify an event and the script that's associated with it, if there is none, create one. If you don't find the event at first, consider inheritance and look for it in a superclass. In this case you need to decide whether you want to override the superclass's behavior or expand it. The special variable "super" comes in handy for this...
On modding Scratch
One thing I really, really want to emphasize is, that "modding'" a complex application like Scratch is not something that would be your first ever project when learning a new programming language, or when starting to program in the first place.
I know that it's deceptively easy to just change a couple of settings and to use some of the nice scripting features that the Scratch team has put in there to very quickly churn out some blocks of your own and bring some hidden features to life that are already existent but turned off (like cloning, the mesh network, web-blocks, more graphics effects, stretch, GUI-features, the "skin" etc. etc.). However, this kind of fidgeting on the surface of the Scratch source code may actually be an obstactle for you to learn programming on your own. And it may even teach you some programming styles that you really should not take on at all, especially about models and GUI's.
Don't get me wrong: I do believe that one of the best ways to learn a musical instrument is to just fool around with it and to find out which sounds come out of it most easily. But at some point you want to know about musical scales, harmony, rhythm, and how to perform some of the more challenging etudes on that instrument, because you want to make the instrument play music that's first in your head and not just in the instrument. Also, long-time pros sometimes have a very different way of handling a musical instrument than most other musicians, but that doesn't mean that their way is any easier or even better than the normal way. In fact, most of the time it isn't. You should know that there is quite a lot of this "pro" style coding in the Scratch source that you don't want to aquire for yourself. Does that make sense to you?
So here's my tip for you, Billybob-Mario: Now that you've successfully learned Smalltalk, download a better programming environment (I recommend either a current Squeak or Pharo - because the Scratch source IDE is optimized especially for dealing with Scratch, has quite a few bugs and glitches on the development side that don't affect the Scratch user side and lacks some useful programming tools found in the bigger and more current environments) and then create something new with it. How about a game or an animation? Learn to design something from scratch, decide which classes you are going to need, think about a model and a separate GUI (something you should not mimick from the Scratch source code, because, cool as it is, it's not the agreed-upon way for GUIs). There are now fantastic tutorials and step-by-step examples and I'm sure you'll be able to come up with some really cool ideas yourself!
One more thing -- and I find this especially painful to acknowledge: Smalltalk/Squeak may not be the best programming language for everyone and everything. Smalltalk is a big, complex integrated system ("image") that's excellent for building large-scale applications with lots of classes. Squeak has a Morphic framework that's brilliant for inventing totally new complex GUI's. Both of these need a lot of ahead-planning and very careful prototyping/refactoring just to get started. Often times you might be quicker and better off to set out with a little Python or JavaScript (or Scheme!) script or - and I'm dead serious about this - with Scratch or BYOB!
Last edited by Jens (2010-09-14 04:21:49)
Offline
Jens wrote:
... and I find this especially painful to acknowledge ... and I'm dead serious about this - with Scratch or BYOB!
Being an old - ahm, relatively - old man, I can see that this was a bitter pill to prescribe. The whole modding phenomenon reveals to me a less obvious side of Scretch: its beauty, simplicity and its - mostly intentional - limitations arouse the curiosity about what's behind the facade, what makes it "tick".
One could call it "learning by hacking": as a kind of "hunting adventure" fun. Following Jens's well thought and well put advice would appear to miss out on this crucial motivation. The musical instrument analogy implies patient exercise and slow methodical advances. But where is the fun and the excitement in that?
Isn't a lot of what drives Scratch/BYOB about motivating young people to learn programming? It appears to me that it might be a great idea to design/create a path for "learning by hacking" through "hidden" and "undiscovered" "back doors" and "dangerous paths" in Scratch/BYOB such that it won't be necessary to give "dead serious" advice to the inquisitive and "adventurous". How hard could that be? (eg. see the once famous BYOB "Easter eggs")
That said, I agree that serious proficiency (well, in anything) requires "covering the basics", but my point here is that if we as educators do it right, we wont have to "recommend it to the student" explicitly and painfully - they'll "get" it by themselves!
Offline
This time I think I've really found it: ReporterBlockMorph's showValue. I even know what part to add to, but not what to add. How can I convert Form(132xi52x32) or whatever that is into an image?
showValue
| gotError msg tooltip w worldBounds |
(#(doReport doMakeNewList doCallWithArgs doPauseThreadReporter) includes: selector) ifTrue: [^self showLambdaValue ].
"
(self allMorphs detect: [:m | (m isKindOf: ReporterBlockMorph) and: [m isSpecialForm]] ifNone: [nil])
isNil ifFalse: [ receiver ifNotNil: [^ self showLambdaValue]].
"
gotError _ false.
[msg _ self evaluate ] ifError: [
gotError _ true.
msg _ 'Error!'].
(msg isKindOf: Morph)
ifTrue: [msg _ msg imageForm ]
ifFalse: [msg _ msg asString ].
(self isBooleanReporter or: [msg = 'Error!']) ifTrue: [
msg _ msg localized].
(self isCostume) ifTrue: [
msg _ msg ADD SOMETHING HERE!].
tooltip _ (ScratchReporterToolTipMorph string: msg for: self)
left: self right;
bottom: self top.
ScratchTranslator isRTL ifTrue: [tooltip right: self left].
gotError ifTrue: [tooltip messageColor: Color red darker].
w _ self world.
w addMorphFront: tooltip.
((worldBounds _ w bounds) containsRect: tooltip bounds) ifFalse:
[tooltip bounds: (tooltip bounds translatedToBeWithin: worldBounds)].
self setProperty: #toolTip toValue: tooltip.
tooltip initialCursorPoint: Sensor cursorPoint.
tooltip startStepping.What do I need to add? (to change a form from text to an image)
Last edited by Billybob-Mario (2010-09-14 07:09:52)
Offline
Hi Marc,
marc_hr wrote:
One could call it "learning by hacking": as a kind of "hunting adventure" fun. Following Jens's well thought and well put advice would appear to miss out on this crucial motivation. The musical instrument analogy implies patient exercise and slow methodical advances. But where is the fun and the excitement in that?
Oh, don't get me all wrong: I'm a hacker and I love hacking, and I'm also a musician, and I can tell you that I'm not a great fan of violin etudes.
Of course the fun is all in plunging right in and just fooling around, trying every illicit backdoor that you can find! I even believe that this is the only way that really works. That's what I've been trying to tell Billybob-Mario all along: You just g... do it, and you don't ask to be taken by the hand when venturing out into the wild, and you don't ask for directions to India if you're being Christopher Columbus, you just discover America instead!
BUT, If you can't stand the dark then don't go out at night. If you're constantly getting all lost then maybe you should consider a different path.
Smalltalk is my passion and Scratch is the greatest Smalltalk application around, and the Scratch source code is a piece of art, but maybe not for everybody. All I'm trying to make clear is that you don't have to mod Scratch to get the most out of it.
marc_hr wrote:
my point here is that if we as educators do it right, we wont have to "recommend it to the student" explicitly and painfully - they'll "get" it by themselves!
Yeah, you hear that, my friend Billybob-Mario? "by themselves" is the crucial point here. Now go outside and play
Last edited by Jens (2010-09-14 09:13:49)
Offline
Billybob-Mario, please excuse me for seizing the thread and helping to turn it into a lengthy didactic theory discussion. Obviously, what you wanted was just a "little hint" from the pros - then you'd be back on your feet again ...
Now instead of the hoped for indication you get reprimanded with a smiley
Jens wrote:
If you're constantly getting all lost then maybe you should consider a different path.
"What is he talking about", you might ask:
Jens wrote:
Now go outside and play
???
You are probably convinced that you're doing just that! You're out there, you're searching, trying your best - and BTW: what's wrong with getting lost?
Billybob-Mario - if I were you, and I don't mean that in a patronizing way, I'd put it to Jens this way: "I respect you a lot, please don't lose your patience with me - maybe what I'm out here to discover is not so much this or that Smalltalk hack, it maybe hasn't even much to do with programming - just might have seemed an opportunity that I came across - what I really need from you is to show me: HOW to do it on my own!"
Jens, while this might seem so natural to you, it can be the hardest thing in the world for others. Billybob-Mario - no offense, my point: you don't have to give up, just because you might feel bad about "nagging" people with questions and appearing "constantly" lost. When someone loses hes/her patience with you, maybe they have a point - you should re-check your approach. But that's a long shot from giving up on "going out in the night" as someone might have suggested
Offline
U-oh, now I'm the one who's getting reprimanded for not being helpful
Serves me right after my last post, I guess.
So Marc, if you read some of the BYOB threads - as well as this one - you'll surely notice that I'm almost constantly giving hints (especially to BBM - often very concrete). And while I do admit to being tired of re-answering the kind of questions that I have already taken some effort to respond to in a decidedly indirect (i.e. avoiding explicit "how-tos") way I eventually always answer them anyway.
But I also want to give BBM a break, beause there's this frenzy about modding going on in the forums which I'm afraid sometimes conveys the wrong impression that if you don't "work on a mod" you're not an "advanced" Scratcher.
Offline
Bobberpi wrote:
I have a question about BYOB-
I was making a Point towards X) Y
) Block, and instead of making a variable called X, It made a drop-down list that said "Record" and "Re Record". What is that?
Hi Bobberpi,
I can't reproduce this bug, but I'd very much like to fix it anyway. Can you please tell us exactly what you did? Thanks!
Offline
I'm not losing my patience, and I think that I've learned a lot about toolTips and how a reporter block reports. Can I at least get a general direction of where to look for the method to make it change Form(axbxc) into an image? I know where to put it, and I said in my last post. Also, thank you for helping me now and in the past.
Offline
Jens wrote:
Bobberpi wrote:
I have a question about BYOB-
I was making a Point towards X) Y
) Block, and instead of making a variable called X, It made a drop-down list that said "Record" and "Re Record". What is that?
Hi Bobberpi,
I can't reproduce this bug, but I'd very much like to fix it anyway. Can you please tell us exactly what you did? Thanks!
Oh, y'know, I bet it's because of a %x bug, that's the spec for scene names.
Offline
Jens wrote:
respond ... in a decidedly indirect (i.e. avoiding explicit "how-tos") way
I agree, this is precisely what I meant: point the way, but let them discover the details by themselves. Beyond being "didactic" the added value of this approach is the greater generality of the answers that can be reapplied to other similar questions.
Jens wrote:
I do admit to being tired of re-answering the kind of questions that I have already taken some effort to respond ...
I truly believe that and I've also seen how much mind and heart you commit to the task of relating to the users, myself included. I'm really sorry for making the impression of "reprimanding" you, my intention was to humbly point out that losing patience, especially when justifiably so, can be misleading.
In this situation, what you call "this frenzy about modding", a well stocked FAQ thread or if the resources allow it a small Q&A wiki can come to the rescue and instead of having to repeat yourself until exhaustion you could just refer them to the related issue from an earlier question.
I would assume that I'd be preaching to the quire when I state my belief that BYOB deserves its own dedicated forum, separate from advanced/hacking Scratch, with a more fine grained resolution of subjects. Then again, there are political/organizational, resources and user-base issues to consider that I know nothing about...
Anyway, thanks Jens for what you did and continue doing for the Scratch/BYOB community!
Offline
Hey Billybob-Mario,
a Form in Squeak is a picture object.
So, where do you get the Form from? If it's from another Morph (as I suppose, e.g. by calling #imageForm) then you can just as well pass that other Morph as msg to the tool tip. If, on the other hand, you're generating the Form yourself you can either put it into a new ImageMorph (hint: browse that class to find out how) and pass that to the tool tip, or change the method you've found in a way so that it can directly handle Forms, for example like this:
...
(msg isKindOf: Morph)
ifTrue: [msg := msg imageForm ]
ifFalse: [(msg isKindOf: Form)
ifFalse: [ msg := msg asString ]].
...See, it's finally turned into a How-To
(Does that help?)
Last edited by Jens (2010-09-14 15:20:48)
Offline