thanks for the info Nicolai, what I am trying to do is super simple, as you can see from the code I linked I have a very simple interface of a single button, I want to put before that button a simple morph to display color.��

Basically the button changes the background color of windows and I want the morph to display the color. Morph wise i can create the Morph like this

backgroundColorMorph := Morph new.
backgroundColorMorph color: self backgroundColor.

the problem is how I add this Morph to my gui. Meaning how to wrap it as spec widget which is what your code is doing. I was not aware of asSpecAdapter. Documentation does not mention this in Pharo for the Enterprise Spec Chapter.��

So following your instructions i added to my initialise method

backgroundColorMorph := Morph new.
backgroundColorWidget := backgroundColorMorph asSpecAdapter .

I added a method to return backgroundColorWidget with the same name and changed at class side defaultSpec to

defaultSpec
<spec>
^ SpecLayout composed
newRow: [:r | r add: #button width: 25. r add: ��#backgroundColorWidget]
; yourself

I try to open the Spec gui and gives me a MNU Morph>>layout:��

Am I suppose to add some form of layout to the morph ?��

Do I need to add something to initialiseWidgets ?��

On Sun, Nov 16, 2014 at 12:36 PM, Nicolai Hess <nicolaihess@web.de> wrote:
2014-11-16 10:02 GMT+01:00 kilon alios <kilon.alios@gmail.com>:
Hello guys I am trying to add a morph to spec gui before a spec button and the experience has been a nightmare so far.


What do you mean "add a morph to spec gui". The common way is to define your own model and instead of composing
your GUI with different morphs, you compose your GUI with different (ready-made) models. If you need a new
kind of 1 model-GUI-Widget you'll have to define your own spec (morphic)adapter and add a spec binding.

If you just want to add an existing morph into your layout, you can use Morphic>>#asSpecAdapter.

This example looks a bit ugly, just because it uses a DynamicComposableModel. In your own
applicatoin you would define your own model for defining and composing the parts:


class:=AthensFlakeDemo.
method:=AthensFlakeDemo>>#initialize.
composed:= DynamicComposableModel new.
composed instantiateModels: #(code TextModel method TextInputFieldModel).

"this is a hack, as #instantiateModels: does not work for non-spec-models"
composed widgets at:#demo put:(AthensFlakeDemo new asSpecAdapter).

"with your own model (instead of using DynamicComposableModel) you would"
"define a method that returns the morph asSpecadapter "

composed code text:method sourceCode.
composed method text: method selector asString.
composed code aboutToStyle:true.
composed code behavior:class.
composed title:(class asString).
composed openWithSpecLayout:(
SpecLayout composed
newColumn:[:r | r
add: #demo height:80;
add: #method height:25;
add: #code];
yourself).





��

I understand how columns and rows work but I cant figure out how Spec works with Morphs.

I took a look at CheckBoxExample but it completely jammed my brain how complex it looks.

First of all defaultSpec2 is what ? and whats the diffirence with defaultSpec ?��

Dont know about you but I don't like neither name defaultSpec and defaultSpec2 , I would have chosen a name like layout or something that makes sense.��

also why we need to initializeWidgets when we already define their order in defaultSpec ? Why cant Spec initialise those widgets by itself ?

Is it really necessary for each element of the gui to be defined as a getter method ? Why not just put everything to a dictionary and make a getter for that dictionary ? It would make a complex Spec gui a nightmare to browser and leads to braking it up to more classes which will still make it a mess to browse.��

I see also ��a container defined in there , I assume it has something to do with the morphs.��

I took also a look at documentation at Pharo for the Enterprise and it has a section for building widgets but it looks too much work to add just a few morph to a Spec gui.��

I wanted to make the gui for Nireas with Spec and I like some of its design but overall it has been way more struggle than working with Morphic.��

I know I have complained about Spec before and sorry if I sound like a broken tape but making guis in heavily gui based environment like Pharo should not be so hard.��

I dont have a problem failing back to Morphic but since I see so many people praise Spec I keep wondering if I approach this the wrong way and things are much more elegant and easy than they look.��