Hi Lukas,
> Another issue currently is the customization of a
description if it
> depends on the instance of the structure. For instance, one would like
> to have elements in a select list that are dependent on the instance
> of a structure and that cannot be determined statically. As far as I
> understand the only possibility to achieve that is to override
> #description on the instance-side and to add the desired
> instance-dependent elements there. Or am I mistaken here?
Another powerful thing is the MADynamicObject class,
that
allows to define descriptions where you don't know the
possible properties in advance. Try something like:
B class>>optionsToBeUsed
^MADynamicObject on: [ 1 to: 100 atRandom ].
Sorry, I don't understand how this is then dependent on the instance,
because this is still on the class side, no?
I have checked MADynamicObject, but I don't see how can I bring in some
instance-based properties?
Maybe I did't clarify my problem well enough, so here's an example of what I
would like to do:
A >> elements
^Array with: instvar1 with: instvar2 with: instvar3
A class >> descriptionElements
^(MAOptionsDescription key: #foo)
options: (MADynamicObject on: [ "how can I get
access to A >> elements here?" ]);
yourself.
So I need a way to get the options from instances of the class in which I
define the description.
Maybe something like a block, such as MADynamicObject on: [:instance |
instance elements]. When the options component (select list, radio buttons,
...) is built up, the arg of the block should be bound to the concrete
instance of A and then the options are fetched from the #elements method of
this instance.
As I said, so far I add the options answered by #elements to the options
description in A >> description, an override of Object >> description.
It is also possible to clear a description element in
a
subclass, by overriding the description method and returning nil
C class>>descriptionFoo
^nil
or you could change the description of the superclass by modifying it:
C class>>descriptionFoo
^super descriptionFoo
beReadonly;
nilLabel: 'nothing';
yourself.
Yep, I have seen that, indeed very useful.
David