0

我正在使用Pharo 3中的Spec 库,但我发现无法将标题添加到多列列表中。但是,通过 TreeColumnModel 和 TreeModel 添加标题是可行的,如下所示:

| m col1 col2 |
m := TreeModel new.
m roots: #(#a #b #c #d).
m rootNodeHolder: [ :item | 
    TreeNodeModel new
        content: item;
        icon: Smalltalk ui icons smallConfigurationIcon ].
m openWithSpec.
col1 := TreeColumnModel new
    displayBlock: [ :node | node content asString ];
    headerLabel: 'Character'.
col2 := TreeColumnModel new
    displayBlock: [ :node | (Character value: node content asString first asciiValue + 1) asString ];
    headerLabel: 'Character +1';
    headerIcon: Smalltalk ui icons smallBackIcon.
m
    columns: {col1. col2};
    acceptDropBlock: [ :transfer :event :source :receiver | self halt ].
col2 
    headerLabel: 'Character +2';
    headerIcon: Smalltalk ui icons smallBackIcon;
    displayBlock: [ :node | (Character value: node content asString first asciiValue + 2) asString ].
m rootNodeHolder: [ :item | 
    TreeNodeModel new
        content: (Character value: (item asString first asciiValue + 5)) asSymbol;
        icon: Smalltalk ui icons smallFullscreenIcon ].

如何在以下 MultiColumnListModel 中获得标题?

MultiColumnListModel new
    items: {$a. $b. $c. $d. $f.};
    displayBlock: [:e | {e asString. e isVowel asString} ];
    openWithSpec.
4

1 回答 1

0

这对你有用吗?

    model := MultiColumnListModel new
    items: { {'Letter'. 'isVowel'.}. $a. $b. $c. $d. $f.};
    displayBlock: [:e | 
    e isArray 
    ifTrue:[{e first asString. e last asString} ]
    ifFalse:[
    {e asString. e isVowel asString} ]].
model 
    whenSelectionChanged:[  
        model getIndex  =  1 ifTrue:[       
        model setIndex:0].
    ];
    openWithSpec. 
于 2014-07-27T11:41:09.400 回答