【问题标题】:Adding a header to MultiColumnListModel向 MultiColumnListModel 添加标题
【发布时间】:2014-07-22 03:51:34
【问题描述】:

我正在使用Pharo 3 中的Spec library,但我发现无法将标题添加到多列列表中。但是,通过 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.

【问题讨论】:

    标签: user-interface smalltalk pharo spec-ui


    【解决方案1】:

    这对你有用吗?

        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. 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-23
      • 1970-01-01
      • 1970-01-01
      • 2011-10-21
      • 1970-01-01
      相关资源
      最近更新 更多