[squeak-dev] Re: Maui questions

Douglas McPherson djm1329 at san.rr.com
Fri Jan 11 21:57:51 UTC 2013


Agreed, that's really handy. Thanks so much.  


On Jan 9, 2013, at 18:09 , Chris Muller <asqueaker at gmail.com> wrote:

> I happened across another great example I forgot to mention.
> 
> If you send #maui your NetworkMessage instance, then select tools |
> loaded it will build a *tabbed view* of messages by category, a tab
> per category.  Almost like a "behavioral inspector".
> 
> It's simply a quick way of aggregating the widgets in a legal way
> (e.g., you could do it manually with a lot of clicks) to provide a
> good starting point ready for manual customization -- mostly by simply
> _removing_ items, which is very nice because that's easier than
> "building up" from a blank canvas.
> 
> The code that builds that is MauiDomainMorph>>#loaded should you wish
> to adapt it.
> 
> 
> 
> On Wed, Jan 9, 2013 at 11:25 AM, Douglas McPherson <djm1329 at san.rr.com> wrote:
>> 
>> On Jan 8, 2013, at 16:12 , Chris Muller <asqueaker at gmail.com> wrote:
>> 
>> 
>>> Hi, thanks for the great feedback!
>>> 
>>>> I've got a set of classes that represent the messages of a network protocol which can be serialized and sent
>>>> over a socket, stored in byte arrays, etc. Essentially, the fields of the messages are stored in instance vars,
>>>> and there are getter/setter accessors for each.
>>> 
>>> Wow, just fyi, that is _exactly_ what Ma-Client-Server does.  :)
>>> Sounds like you have a very similar need and solution.
>>> 
>>>  http://wiki.squeak.org/squeak/2978
>>> 
>> 
>> Thanks for your responses. I'll definitely check out Ma-Client-Server.
>> 
>> 
>>>> I'm trying to build a Maui interface to allow me to select an arbitrary one of the messages (classes), fill in its
>>>> values, then pick it up and drop it onto a Maui morph wrapping a socket connection, and thus send the
>>>> message.
>>>> I can explicitly (manually) create a MauiMorph for a specific message (instance of a class) in my protocol,
>>>> drop the accessor selectors, and make them be getter/setters. I can fill in the fields of such a message and
>>>> drop it onto the socket-wrapping MauiMorph. The message gets sent properly. I wish to build a more generic
>>>> MauiMorph that allows me to select which message of the network protocol (class) to build, then have the
>>>> accessors for that particular class automatically render in a panel, ready for filling in. I'm trying to avoid
>>>> manually creating views for each of the message types.
>>> 
>>> No problem, in fact there is already a nearly identical example of
>>> doing that with MauiColorSchemMorph.  It adds a getter/setter for each
>>> method in a particular category.  Make a copy of that class which also
>>> inherits from MauiDomainMorph.  It has just two short methods!  Please
>>> examine these to see how its done.
>>> 
>>> Lo and behold, the code there even sets up pickers for each of the
>>> getter/setter messages!   :)   Obviously we are really thinking alike!
>>> 
>>> It's up to you but I typically I call my specialized MDM subclasses,
>>> Maui[DomainClassName]Morph, so, in your case perhaps it would be,
>>> MauiNetworkMessageMorph.
>>> 
>>> Once you have your new subclass, there is one final step.  You have to
>>> tell Maui to USE that subclass for instances of your NetworkMessage
>>> domain class.  Here's how that's done:
>>> 
>>> MauiRegistry global
>>> register: MauiNetworkMessageMorph
>>> forAny: NetworkMessage
>>> 
>>> A good place to do that is in the class-side #initialize method for
>>> MauiNetworkMessageMorph.
>>> 
>>> Now, creating a subclass of MauiDomainMorph will create a dependency
>>> on Maui for your app.  What I typically do to manage that is simply
>>> make a "-Maui" version of the package which can be optionally loaded.
>>> 
>> 
>> Yup, works perfectly, just as you described! One very short method in a new subclass of MauiDomainMorph did the trick. Thanks.
>> 
>> 
>>>> I tried to implement a 'picker' on a parameter holder but I can't figure out how to do it. Of course I can get an
>>>> array of all the existing message subclasses and I can get that to render as a MauiCollectionMorph, but I
>>>> can't see how to make this list be the choices of the picker. (I tried 'maui this morph' on the
>>>> MauiCollectionMorph). I'm after functionality similar to the way the selectStrategy: parameter holder (in the
>>>> MauiMessage settings panel) pops up a list of strategy classes and allows the user to select one of them.
>>>> Also, I need to know how to populate the set of accessors particular to the selected message's fields.
>>> 
>>> The only limitation to pickers is that they should not contain domain
>>> objects -- otherwise the Maui panels cannot be saved "purely" (e.g.,
>>> without any domain classes).  So rather than actual classes, you
>>> should have class names (Symbols) in your pick-list.
>>> 
>>> You already know how to make pickers work via code by the
>>> MauiColorScheme example above.  To do it graphically, I hope you won't
>>> mind if I first try to refer you to page 40 of the Maui User Guide
>>> under the heading "Specifying an Object "Picker".  The guide is here:
>>> 
>>> http://wiki.squeak.org/squeak/uploads/3836/Maui1.1r1.pdf
>>> 
>>>> Another approach I tried (and couldn't make work) is to override the default behavior when a class is picked up from a browser and dropped onto the desktop. Instead of creating a MauiMorph on that class, I wished to create a MauiMorph on an instance of the class with all accessor MauiMessageMorphs already built. I tried overriding the 'maui' method on the class side, in which I send 'maui' to a new instance, programmatically add the accessors with 'addMessageNamed:' and return the result. Overriding 'maui' didn't work … is there an easy way to do this? (A side question: how can I programmatically add a method and have it be a getter/setter?).
>>> 
>>> I think I answered this above, please let me know if I missed something.
>> 
>> 
>> As you indicated, my mistake was using a list of classes instead of a list of symbols. Works great now.
>> 
>> The network protocol I am modeling has the possibility of optional (and variable width) fields, which may depend on the value of other fields in the same message. Is it possible to arrange that the MauiDomainMorph panel is re-rendered when certain fields have their value changed (so that other MauiMessageMorphs can be included or not as necessary) ? Also, I'm trying to figure out how to display and edit arrays -- both arrays of standard objects like byte or float, and arrays of NetworkProtocol messages themselves. I have played with MauiCollectionMorph, but I couldn't figure out how to alter the values. Somehow I need a getter/setter on each element?
>> 
>> Thanks again! I am imagining dozens of situations where I can use Maui to offer quickly and easily developed UIs.
>> 
>> 
>> 
>> 
>> 
>> 
>> 



More information about the Squeak-dev mailing list