ComboListView.st
author Claus Gittinger <cg@exept.de>
Sat, 06 Sep 1997 19:47:37 +0200
changeset 519 9ab4fc771a7f
parent 501 0f047737ba92
child 536 918612416568
permissions -rw-r--r--
better look with 2D styles
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     1
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     2
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     3
              All Rights Reserved
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     4
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     5
 This software is furnished under a license and may be used
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     6
 only in accordance with the terms of that license and with the
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     8
 be provided or otherwise made available to, or used by, any
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     9
 other person.  No title to or ownership of the software is
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    10
 hereby transferred.
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    11
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    12
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    13
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    14
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
ComboView subclass:#ComboListView
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    16
	instanceVariableNames:'useIndex values'
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	category:'Views-Interactors'
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
270
35558a88d500 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    22
!ComboListView class methodsFor:'documentation'!
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    24
copyright
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    25
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    26
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    27
              All Rights Reserved
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    28
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    29
 This software is furnished under a license and may be used
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    30
 only in accordance with the terms of that license and with the
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    32
 be provided or otherwise made available to, or used by, any
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    33
 other person.  No title to or ownership of the software is
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    34
 hereby transferred.
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    35
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    36
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    37
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    38
!
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    39
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
documentation
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    A ComboListView combines an label with a drop down list of default inputs;
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    choosing any from the pulled list sets the string in the label.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    This is the same as a PopUpList or SelectionInListView, bit looks different.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    47
    The preferred model is a SelectionInList, but a simple valueHolder
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    48
    may also be used. 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    49
    If some other model is to be used, the changeMessage and aspectMessage 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    50
    should be defined as appropriate (or an aspectAdaptor should be used).
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    51
    If a listHolder is set, that one is assumed to provide the list of
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    52
    items in the popped menu; 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    53
    otherwise, if listMessage is nonNil, the model is assumed to also provide the
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    54
    list as displayed in the popped menu.
275
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    55
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    56
    [author:]
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    57
        Claus Gittinger
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    58
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    59
    [see also:]
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    60
        ComboView
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    61
        PopUpList SelectionInListView
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    62
        ComboBoxView
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    63
        PullDownMenu Label EntryField
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
examples
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    69
  non-MVC use; 
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    70
    set the list explicitely:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    71
                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    72
     |top comboBox|
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
     top := StandardSystemView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
     top extent:(300 @ 200).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    77
     comboBox := ComboListView in:top.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    78
     comboBox origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    79
     comboBox bottomInset:(comboBox preferredExtent y negated).
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    81
     comboBox list:#('hello' 'world' 'this' 'is' 'st/x').
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
     top open.
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    83
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    87
    with callBack:
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    88
                                                                [exBegin]
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    89
     |top b|
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    90
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    91
     top := StandardSystemView new.
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    92
     top extent:(300 @ 200).
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    93
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    94
     b := ComboListView in:top.
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    95
     b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    96
     b bottomInset:(b preferredExtent y negated).
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    97
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    98
     b list:#('hello' 'world' 'this' 'is' 'st/x').
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
    99
     b action:[:selected | Transcript showCR:selected].
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   100
     top open.
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   101
                                                                [exEnd]
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   102
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   103
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   104
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   105
    with values different from the label strings:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   106
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   107
     |p|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   108
     p := ComboListView label:'dummy'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   109
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   110
     p selection:'apples'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   111
     p values:#(10 20 30 40 nil 50).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   112
     p action:[:what | Transcript show:'you selected: '; showCR:what].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   113
     p open
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   114
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   115
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   116
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   117
    with separating lines:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   118
                                                                [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   119
     |p|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   120
     p := ComboListView label:'fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   121
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   122
     p selection:'apples'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   123
     p open
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   124
                                                                [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   125
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   126
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   127
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   128
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   129
    sometimes, you may like the index instead of the value:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   130
    (notice, that the separating line counts, so you have to take care ...)
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   131
                                                                [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   132
     |p|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   133
     p := ComboListView label:'dummy'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   134
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   135
     p selection:'apples'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   136
     p action:[:what | Transcript show:'you selected: '; showCR:what].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   137
     p useIndex:true.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   138
     p open
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   139
                                                                [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   140
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   141
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   142
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   143
    since the list is actually represented by a menuView,
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   144
    which itself is inheriting from listView, which itself can display
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   145
    things different from strings, arbitrary lists can be constructed:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   146
    (see ListEntry, LabelAndIcon and Text classes)
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   147
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   148
     |p l|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   149
     p := ComboListView label:'dummy'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   150
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   151
     l := OrderedCollection new.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   152
     l add:(Text string:'apples' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   153
     l add:(Text string:'bananas' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   154
     l add:(Text string:'grape' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   155
     l add:(Text string:'lemon' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   156
     l add:'='.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   157
     l add:(Text string:'margaritas' color:Color green darkened darkened).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   158
     l add:(Text string:'pina colada' color:Color green darkened darkened).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   159
     l add:'='.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   160
     l add:(Text string:'smalltalk' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   161
     l add:(Text string:'c++' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   162
     l add:(Text string:'eiffel' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   163
     l add:(Text string:'java' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   164
     p list:l.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   165
     p values:#(apples bananas grape lemon 
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   166
                nil 
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   167
                'mhmh - so good' 'makes headache'
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   168
                nil
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   169
                'great' 'another headache' 'not bad' 'neat').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   170
     p selection:'apples'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   171
     p action:[:what | Transcript show:'you selected: '; showCR:what].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   172
     p open
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   173
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   174
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   175
    with values different from the label strings:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   176
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   177
     |p|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   178
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   179
     p := PopUpList label:'language selection'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   180
     p list:( #(
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   181
                'usa'
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   182
                'uk'
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   183
                'france'
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   184
                'germany'       
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   185
                'italy'
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   186
               ) collect:[:country |
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   187
                            LabelAndIcon 
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   188
                                icon:(Image fromFile:'bitmaps/xpmBitmaps/countries/' , country , '.xpm')
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   189
                                string:country
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   190
                         ]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   191
            ).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   192
     p values:#(us england france germany italy).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   193
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   194
     p action:[:what | Transcript show:'you selected: '; showCR:what].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   195
     p open
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   196
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   197
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   198
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   199
  with a model (see in the inspector, how the index-holders value changes)
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   200
  the defaults are setup to allow a SelectionInList directly as model:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   201
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   202
     |p model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   203
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   204
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   205
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   206
     p := ComboListView label:'healthy fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   207
     p model:model.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   208
     p open.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   209
     model inspect
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   210
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   211
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   212
  model provides selection; list is explicit:
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   213
                                                                [exBegin]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
     |model top b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
     model := 'foo' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
     top := StandardSystemView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
     top extent:(300 @ 200).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
     b := ComboListView in:top.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
     b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
     b bottomInset:(b preferredExtent y negated).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
     b list:#('hello' 'world' 'this' 'is' 'st/x').
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   226
     b model:model.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
     top openModal.
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   229
     Transcript showCR:('comboBox''s value: ' , model value).
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   230
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   233
    a comboListView and a SelectionInListView on the same model:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   234
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   235
     |p slv model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   236
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   237
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   238
     model selection:'apples'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   239
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   240
     p := ComboListView on:model.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   241
     p open.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   242
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   243
     slv := SelectionInListView on:model.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   244
     slv open.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   245
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   246
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   247
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   248
    two comboListViews on the same model, different aspects:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   249
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   250
     |top panel p model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   251
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   252
     model := Plug new.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   253
     model respondTo:#eat: with:[:val | Transcript showCR:'eat: ' , val].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   254
     model respondTo:#drink: with:[:val | Transcript showCR:'drink: ' , val].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   255
     model respondTo:#meals with:[#(taco burrito enchilada)].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   256
     model respondTo:#drinks with:[#(margarita water corona)].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   257
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   258
     top := StandardSystemView new.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   259
     top extent:(150@150).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   260
     panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   261
     panel horizontalLayout:#fitSpace.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   262
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   263
     p := ComboListView label:'meals'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   264
     p model:model; listMessage:#meals; aspect:nil; change:#eat:.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   265
     panel add:p.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   266
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   267
     p := ComboListView label:'drinks'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   268
     p model:model; listMessage:#drinks; aspect:nil; change:#drink:.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   269
     panel add:p.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   270
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   271
     top open
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   272
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   273
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   274
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   275
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   276
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   277
    with separate list- and indexHolders:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   278
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   279
     |p selectionHolder listHolder|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   280
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   281
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   282
     selectionHolder := 'apples' asValue.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   283
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   284
     p := ComboListView label:'healthy fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   285
     p listHolder:listHolder.
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   286
     p model:selectionHolder.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   287
     p open.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   288
     selectionHolder inspect
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   289
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   290
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   291
    using different values:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   292
                                                                        [exBegin]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   293
     |p selectionHolder listHolder values|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   294
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   295
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   296
     values := #(apples bananas grape lemon alcohol).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   297
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   298
     selectionHolder := #alcohol asValue.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   299
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   300
     p := ComboListView label:'healthy fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   301
     p listHolder:listHolder.
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   302
     p model:selectionHolder.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   303
     p values:values.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   304
     p open.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   305
     selectionHolder inspect
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   306
                                                                        [exEnd]
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   308
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
  in a dialog:
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   310
                                                                [exBegin]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
     |model1 model2 dialog b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
     model1 := 'foo' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
     model2 := 'bar' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
     dialog := Dialog new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
     (dialog addTextLabel:'ComboList example:') adjust:#left.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
     (b := dialog addComboListOn:model1 tabable:true).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
     b list:#('fee' 'foe' 'foo').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
     (b := dialog addComboListOn:model2 tabable:true).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
     b list:#('bar' 'baz' 'baloo').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
     dialog addOkButton.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
     dialog open.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   332
     Transcript showCR:('1st comboBox''s value: ' , model1 value).
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   333
     Transcript showCR:('2nd comboBox''s value: ' , model2 value).
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   334
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   338
!ComboListView class methodsFor:'defaults'!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   339
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   340
defaultAspectMessage
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   341
    ^ #selection
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   342
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   343
    "Created: 27.2.1997 / 15:23:13 / cg"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   344
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   345
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   346
defaultChangeMessage
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   347
    ^ #selection:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   348
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   349
    "Created: 27.2.1997 / 15:23:18 / cg"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   350
! !
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   351
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   352
!ComboListView methodsFor:'accessing-behavior'!
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   353
501
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   354
useIndex
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   355
    "specify, if the selected components value or its index in the
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   356
     list should be sent to the model. The default is its value."
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   357
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   358
    ^ useIndex
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   359
!
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   360
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   361
useIndex:aBoolean
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   362
    "specify, if the selected components value or its index in the
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   363
     list should be sent to the model. The default is its value."
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   364
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   365
    useIndex := aBoolean.
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   366
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   367
    "Created: 26.7.1996 / 17:44:18 / cg"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   368
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   369
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   370
values:aCollection
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   371
    "specify, which values are to be stuffed into the model or
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   372
     passed via the actionBlock."
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   373
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   374
    values := aCollection.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   375
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   376
    "Created: 27.2.1997 / 15:10:12 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   377
! !
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   378
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
!ComboListView methodsFor:'accessing-components'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
label 
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   382
    "return the label component"
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    ^ field
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    "Modified: 28.2.1996 / 15:10:50 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    "Created: 28.2.1996 / 15:13:51 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   390
!ComboListView methodsFor:'accessing-contents'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   391
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   392
contents:something
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   393
    "set the current value - either in the fields model
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   394
     or directly"
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   395
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   396
    |m|
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   397
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   398
    (m := field model) notNil ifTrue:[
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   399
        m value:something
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   400
    ] ifFalse:[
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   401
        field label:something
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   402
    ]
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   403
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   404
    "Created: 15.7.1996 / 13:16:49 / cg"
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   405
    "Modified: 5.1.1997 / 00:05:04 / cg"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   406
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   407
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   408
selection:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   409
    "set the contents of my field; questionable"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   410
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   411
    self contents:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   412
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   413
    "Created: 27.2.1997 / 15:07:37 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   414
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   415
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
!ComboListView methodsFor:'initialization'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   418
initialize
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   419
    useIndex isNil ifTrue:[useIndex := false].
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   420
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   421
    super initialize.
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   422
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   423
    "Created: 26.7.1996 / 17:44:57 / cg"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   424
    "Modified: 27.2.1997 / 15:23:24 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   425
!
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   426
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
initializeField
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
    field := Label in:self.
519
9ab4fc771a7f better look with 2D styles
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   429
    field level:-1; borderWidth:0.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
    field adjust:#left.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
     |b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
     b := ComboListView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
     b list:#('hello' 'world' 'this' 'is' 'st/x').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
     b open
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
    "Created: 28.2.1996 / 15:13:46 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
    "Modified: 28.2.1996 / 15:18:40 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   444
!ComboListView methodsFor:'private'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   445
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   446
getValueFromModel
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   447
    |selection idx aspect|
278
4a22889a5730 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
   448
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   449
    (model notNil and:[aspectMsg notNil]) ifTrue:[
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   450
        "/ kludge - try #value if aspect is the default and
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   451
        "/ not understood by the model
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   452
        "/ this allows a valueHolder to be used, even
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   453
        "/ if the aspectMessage was not setup correctly.
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   454
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   455
        aspect := aspectMsg.
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   456
        aspect == self class defaultAspectMessage ifTrue:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   457
            (model respondsTo:aspect) ifFalse:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   458
                aspect := #value
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   459
            ]
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   460
        ].
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   461
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   462
        selection := model perform:aspect.
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   463
        selection notNil ifTrue:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   464
            values notNil ifTrue:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   465
                idx := values indexOf:selection
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   466
            ] ifFalse:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   467
                useIndex ifTrue:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   468
                    idx := selection
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   469
                ] ifFalse:[
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   470
                    self contents:selection.
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   471
                    ^ self.
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   472
                ]
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   473
            ].
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   474
501
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   475
            self contents:(list at:idx ifAbsent:nil)
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   476
        ]
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   477
    ].
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   478
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   479
    "Created: 15.7.1996 / 12:28:53 / cg"
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   480
    "Modified: 28.2.1997 / 13:41:02 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   481
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   482
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   483
!ComboListView methodsFor:'queries'!
65229309ad5e specClass
ca
parents: 283
diff changeset
   484
65229309ad5e specClass
ca
parents: 283
diff changeset
   485
specClass
65229309ad5e specClass
ca
parents: 283
diff changeset
   486
    self class == ComboListView ifTrue:[
65229309ad5e specClass
ca
parents: 283
diff changeset
   487
        ^ ComboListSpec
65229309ad5e specClass
ca
parents: 283
diff changeset
   488
    ].
301
edddd206a2e5 specClass query
ca
parents: 293
diff changeset
   489
    ^ super specClass
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   490
65229309ad5e specClass
ca
parents: 283
diff changeset
   491
65229309ad5e specClass
ca
parents: 283
diff changeset
   492
! !
65229309ad5e specClass
ca
parents: 283
diff changeset
   493
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
!ComboListView methodsFor:'user interaction'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   496
select:anIndex
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   497
    "sent from the popped menu, when an item was selected"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   498
368
c99ef22c72f8 removed unused variable
Claus Gittinger <cg@exept.de>
parents: 332
diff changeset
   499
    |label value chg|
238
6be113228de3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 232
diff changeset
   500
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   501
    values isNil ifTrue:[
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   502
        value := anIndex.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   503
        useIndex ifFalse:[
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   504
            value := list at:anIndex.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   505
        ]
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   506
    ] ifFalse:[
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   507
        value := values at:anIndex
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   508
    ].
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   509
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   510
    label := list at:anIndex.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   511
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   512
    field label:label.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   513
293
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   514
    "
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   515
     ST-80 style model notification ...
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   516
     this updates the model (typically, a ValueHolder)
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   517
    "
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   518
    (model notNil and:[changeMsg notNil]) ifTrue:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   519
        "/ kludge - try #value: if changeMsg is the default and
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   520
        "/ not understood by the model
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   521
        "/ this allows a valueHolder to be used, even
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   522
        "/ if the aspectMessage was not setup correctly.
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   523
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   524
        chg := changeMsg.
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   525
        chg == self class defaultChangeMessage ifTrue:[
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   526
            (model respondsTo:chg) ifFalse:[
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   527
                chg := #value:
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   528
            ]
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   529
        ].
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   530
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   531
        self sendChangeMessage:chg with:value
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   532
    ].
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    pullDownButton turnOff.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
293
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   535
    "
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   536
     ST/X style actionBlock evaluation ...
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   537
    "
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   538
    action notNil ifTrue:[
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   539
        action value:value
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   540
    ].
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   541
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   542
    "Created: 27.2.1997 / 15:18:44 / cg"
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   543
    "Modified: 28.2.1997 / 13:50:17 / cg"
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
270
35558a88d500 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   546
!ComboListView class methodsFor:'documentation'!
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
version
519
9ab4fc771a7f better look with 2D styles
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   549
    ^ '$Header: /cvs/stx/stx/libwidg2/ComboListView.st,v 1.23 1997-09-06 17:47:37 cg Exp $'
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
! !