[Pharo-users] Spec: Binding widgets how to

Nicolai Hess nicolaihess at gmail.com
Sun Jan 3 08:45:30 EST 2016


2015-12-23 16:50 GMT+01:00 Offray Vladimir Luna Cárdenas <offray at riseup.net>
:

> Thanks Nicolai for your minimalist example. Only until now I have time to
> test it (sorry), but I get some "MessageNotUnderstood:
> SpecTreeNodeModel>>layoutFrame:" when I run this:
>
> =================
> | aClass subItems |
> aClass := RTObject.
> subItems := RTObject subclasses.
> "create the node"
> t :=  TreeNodeModel new
>         content: aClass name;
>         hasChildren: [ aClass subclasses notEmpty ];
>         children: [ subItems ifNil:[subItems:=aClass subclasses collect: [
> :s | self buildNodeFor: s ] ]];
>         yourself.
> "listen on selection"
> t whenSelectedChanged: [ :bool | bool ifTrue:[self field text: t content]
> ].
> t openWithSpec
> =================
>

The children block codee only works as part of the class I defined with the
method buildNodeFor:
( it calls "self buildNodeFor:")





>
> There is any way to run a minimal GUI with a tree using your example? I'm
> still missing a key concept on how to use spec and binding between widgets.
>

what is missing ? this is a minimal gui with a tree component.


>
> Thanks,
>
> Offray
>
>
> On 29/11/15 13:51, Nicolai Hess wrote:
>
>
>
> 2015-11-26 19:36 GMT+01:00 Offray Vladimir Luna Cárdenas <
> <offray at riseup.net>offray at riseup.net>:
>
>> Hi,
>>
>> I had tried that before and didn't work. Passing information between
>> widgets and back in this spec interface seems my stop point now... If
>> someone could help me with some kind of minimalist example that uses
>> treeModel, that would be greatly appreciated.
>>
>
> Find attached a minimal example. (I use Morph and its subclasses for
> generating some tree data, these are just names, renaming a node does not
> rename the class :))
>
> You can listen on tree node selection by registering with
> #whenSelectedChanged, on the TreeNode(!)
>
> "create the node"
> t :=  TreeNodeModel new
>         content: aClass name;
>         hasChildren: [ aClass subclasses notEmpty ];
>         children: [ subItems ifNil:[subItems:=aClass subclasses collect: [
> :s | self buildNodeFor: s ] ]];
>         yourself.
>
> "listen on selection"
> t whenSelectedChanged: [ :bool | bool ifTrue:[self field text: t content]
> ].
>
> this will change the text field content with the content of the node (the
> default label).
>
> Changing the label node *Morph* on accepting the text field text is
> somehow impossible or difficult.
> I would have expected that Spec would create a MorphicTreeNodeAdapter that
> represents some Morph, for which the adapter would update/change the state,
> if you change
> the TreeNodeModel content.
> Instead, it creates some strange SpecTreeNodeModel. And the only way to
> update the NodeLabel and make this change visible is to
> rebuild the whole tree:
>
> tree roots: tree roots.
>
> Yes, I did not find another way.
>
> Luckily MorphTreeMorph is smart enough to remember the selection and path
> expansion state, so this works quite well.
>
>
>
>>
>> Cheers,
>>
>> Offray
>>
>>
>> On 26/11/15 12:47, webwarrior wrote:
>>
>>> Try #whenHighlightedItemChanged: method.
>>>
>>> I remember that distinction between selection/highlight is not very
>>> clear in
>>> TreeModel.
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> <http://forum.world.st/Spec-Binding-widgets-how-to-tp4863742p4863757.html>
>>> http://forum.world.st/Spec-Binding-widgets-how-to-tp4863742p4863757.html
>>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>>
>>>
>>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20160103/d15bf721/attachment.html>


More information about the Pharo-users mailing list