Please allow me to simplify my question. I need a basic answer. One of the articles on Morphic says you can create composite morphs either programatically, using addMorph, or using drag and drop from the Objects menu of the morphic World. I have done the latter, because it is easier to design my layout that way. Once that has been done, how do I address the submorph from a browser? If I inspect my button submorph, for example, all it will tell me about it is "a ScriptableButton<Button>(1364754)". I have no idea how to access that object in order to do anything with it. This is the crux of my questions.On Wed, Feb 22, 2017 at 10:03 AM, <[hidden email]> wrote: Send Beginners mailing list submissions to _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Tim,
> One of the articles on Morphic says you can create composite morphs either programatically, > using addMorph, or using drag and drop from the Objects menu of the morphic World. I have > done the latter, because it is easier to design my layout that way. Once that has been done, > how do I address the submorph from a browser? If I inspect my button submorph, for example >, all it will tell me about it is "a ScriptableButton<Button>(1364754)". I have no idea how to > access that object in order to do anything with it. This is the crux of my questions. This is, in my opinion, the most significant limitation of Morphic for interactive GUI creation. In the original Morphic in Self the way to handle this was to simply search through all your submorphs for the one you were interested in, usually by comparing the morphType string. In Squeak we can add properties to Morphs very easily so that would be one way to tag it. Something like: | stopButton | stopButton := nil. self submorphsDo: [ :m | (m hasProperty: #stopButton) ifTrue: [ stopButton := m ] ]. stopButton ifNotNilDo: [ :b | b ... ]. Code like this will work even if there are no stopButtons at all and if you add more than one the code will just use the last one and ignore the others. After creating the button you have to get its halo and use the red button (menu) with the debug->inspect morph option to set the #stopButton property. An alternative to using specially created properties is to depend on the morph's name. In your case it is "a ScriptableButton<Button>(1364754)".. So: self subMorphsDo: [ :m | (m name includesSubString: 'Button') ifTrue: ... should work for you as long as there is only one button. -- Jecel _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Tim Cuthbertson
Hi.
On Wed, Feb 22, 2017 at 10:52 AM, Tim Cuthbertson <[hidden email]> wrote:
Hi, having been through this recently myself, let me share what I do. First, expore the new morph, and name the morph, such as: self name: 'NameString' Then, when you need to find the morph later use #externalName, roughly like what Jecel suggests: | stopButton | stopButton := nil. self allMorphsDo: [ :m | (m externalName = 'NameString') ifTrue: [ stopButton := m ] ]. stopButton ifNotNilDo: [ :b | b ... ]. In my code, I store all of the submorphs I want in local variables for later use. (note that I use #allMorphsDo: - this check morphs embedded in other morphs in your main morph, which I did a lot of!). -cbc _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |