Spec: DropList question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Spec: DropList question

Brad Selfridge
Is there any way for the Spec DropList, when initially painted, to NOT display the first item in the list.

I'm trying to build a dynamic spec window that uses the droplist value to determine what to paint and I want the user to select the droplist item rather than a default.

Thanks,
Brad Selfridge
Reply | Threaded
Open this post in threaded view
|

Re: Spec: DropList question

Peter Uhnak
You can just provide `nil` as the first option, e.g.

ui := DynamicComposableModel new.

ui instantiateModels: #(select DropListModel).

ui select
        items: #(nil a b c);
        displayBlock: [ :each | each ifNil: [ '' ] ifNotNil: #asString ].

layout := SpecLayout composed
        add: #select.

ui openWithSpecLayout: layout.


And then when querying the value check for nil... e.g.

ui select selectedItem ifNotNil: [ :selected | ... ].

Peter



On Sun, Oct 09, 2016 at 06:11:11AM -0700, Brad Selfridge wrote:

> Is there any way for the Spec DropList, when initially painted, to NOT
> display the first item in the list.
>
> I'm trying to build a dynamic spec window that uses the droplist value to
> determine what to paint and I want the user to select the droplist item
> rather than a default.
>
> Thanks,
>
>
>
> -----
> Brad Selfridge
> --
> View this message in context: http://forum.world.st/Spec-DropList-question-tp4918488.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>