[Newbies] [4.1] How do I use ToolBuilder to construct a three pane browser?

Bert Freudenberg bert at freudenbergs.de
Mon Apr 19 11:17:01 UTC 2010


On 19.04.2010, at 12:02, Bert Freudenberg wrote:
> 
> On 19.04.2010, at 11:45, Hannes Hirzel wrote:
>> 
>> Hello
>> 
>> I would like to construct a three pane browser to inspect a dictionary
>> of dictionaries (see data structure example code below). How do I do
>> this using the ToolBuilder? I would like to learn to use it.
> 
> Maybe look at Browser>>buildWith: or all the other buildWith: implementations? No need to subclass DictionaryInspector, I'd simply subclass Model. 
> 
> You would have two lists, and a text pane. Your model will have to provide methods to get the list and get/set the current index. E.g. #lessonList, #lessonListIndex, #lessonListIndex: and #sectionList, #sectionListIndex, #sectionListIndex:.
> 
> When you select something in the lesson list, #lessonListIndex: will be sent. In response, you would send "self changed: #sectionList" which will cause the section list to be updated. Etc.
> 
> - Bert -

After actually having a look, Browser>>buildWith: etc. are already specialized for code tools. No need for that. 

Also, for lists as in your case, working with indices for the selection is less convenient than with objects.

So here's a build method for your model - just implement all the accessors and it works. A complete UI in one method ;)

buildWith: builder
	^builder build:
		(builder pluggableWindowSpec new
			model: self;
			children: {
				(builder pluggableListSpec new)
					model: self;
					list: #lessonList; 
					getSelected: #lesson; 
					setSelected: #lesson:;
					frame: (0 at 0 corner: 0.5 at 0.2).
				(builder pluggableListSpec new)
					model: self;
					list: #sectionList; 
					getSelected: #section; 
					setSelected: #section:;
					frame: (0.5 at 0 corner: 1 at 0.2).
				(builder pluggableTextSpec new)
					model: self;
					getText: #contents;
					frame: (0 at 0.2 corner: 1 at 1).
			})

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.png
Type: image/png
Size: 12397 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100419/0ea15bf9/PastedGraphic-1.png
-------------- next part --------------


- Bert -

PS: I'd consider it cheating if you look at this: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BFLessons.st.gz
Type: application/x-gzip
Size: 839 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100419/0ea15bf9/BFLessons.st.bin


More information about the Beginners mailing list