ComboListView.st
author Claus Gittinger <cg@exept.de>
Sun, 25 Jan 1998 15:14:42 +0100
changeset 679 bd0e422aab67
parent 598 288e67e06da4
child 682 861e446e3b24
permissions -rw-r--r--
fixed model setting & useIndex: handling (aspect)
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
     3
	      All Rights Reserved
332
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    27
	      All Rights Reserved
332
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:]
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    57
	Claus Gittinger
275
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:]
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    60
	ComboView
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    61
	PopUpList SelectionInListView
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    62
	ComboBoxView
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    71
							[exBegin]
307
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.
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    88
								[exBegin]
305
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.
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   101
								[exEnd]
305
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   106
									[exBegin]
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   114
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   118
								[exBegin]
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   124
								[exEnd]
307
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 ...)
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   131
								[exBegin]
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   139
								[exEnd]
307
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)
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   147
									[exBegin]
307
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 
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   166
		nil 
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   167
		'mhmh - so good' 'makes headache'
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   168
		nil
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   169
		'great' 'another headache' 'not bad' 'neat').
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   173
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   176
									[exBegin]
307
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:( #(
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   181
		'usa'
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   182
		'uk'
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   183
		'france'
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   184
		'germany'       
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   185
		'italy'
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   186
	       ) collect:[:country |
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   187
			    LabelAndIcon 
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   188
				icon:(Image fromFile:'bitmaps/xpmBitmaps/countries/' , country , '.xpm')
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   189
				string:country
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   190
			 ]
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   191
	    ).
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   196
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   201
									[exBegin]
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   210
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
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).
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   234
									[exBegin]
307
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.
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   245
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   249
									[exBegin]
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   272
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   278
									[exBegin]
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   289
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   292
									[exBegin]
307
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
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   306
									[exEnd]
307
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:
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
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).
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
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.
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   366
    "/ change the aspetMessage - but only if it has not yet been
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   367
    "/ changed explicitly
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   368
    useIndex ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   369
	aspectMsg == #selection ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   370
	    aspectMsg := #selectionIndex
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   371
	] 
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   372
    ] ifFalse:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   373
	aspectMsg == #selectionIndex ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   374
	    aspectMsg := #selection
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   375
	]
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   376
    ].
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
    "Created: 26.7.1996 / 17:44:18 / cg"
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   379
    "Modified: / 24.1.1998 / 19:06:41 / cg"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   380
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   381
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   382
values:aCollection
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   383
    "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
   384
     passed via the actionBlock."
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   385
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   386
    values := aCollection.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   387
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   388
    "Created: 27.2.1997 / 15:10:12 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   389
! !
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   390
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
!ComboListView methodsFor:'accessing-components'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
label 
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   394
    "return the label component"
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    ^ field
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    "Modified: 28.2.1996 / 15:10:50 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    "Created: 28.2.1996 / 15:13:51 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   402
!ComboListView methodsFor:'accessing-contents'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   403
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   404
contents
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   405
    "get the current value - either in the fields model
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   406
     or directly"
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   407
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   408
    |m|
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   409
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   410
    (m := field model) notNil ifTrue:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   411
	^ m value
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   412
    ] ifFalse:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   413
	^ field label
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   414
    ]
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   415
!
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   416
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   417
contents:something
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   418
    "set the current value - either in the fields model
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   419
     or directly"
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   420
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   421
    |m|
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   422
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   423
    (m := field model) notNil ifTrue:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   424
	m value:something
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   425
    ] ifFalse:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   426
	field label:something
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   427
    ]
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   428
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   429
    "Created: 15.7.1996 / 13:16:49 / cg"
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   430
    "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
   431
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   432
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   433
selection:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   434
    "set the contents of my field; questionable"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   435
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   436
    self contents:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   437
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   438
    "Created: 27.2.1997 / 15:07:37 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   439
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   440
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
!ComboListView methodsFor:'initialization'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   443
initialize
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   444
    useIndex isNil ifTrue:[useIndex := false].
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   445
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   446
    super initialize.
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   447
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   448
    "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
   449
    "Modified: 27.2.1997 / 15:23:24 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   450
!
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   451
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
initializeField
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
    field := Label in:self.
519
9ab4fc771a7f better look with 2D styles
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   454
    field level:-1; borderWidth:0.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    field adjust:#left.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
     |b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
     b := ComboListView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
     b list:#('hello' 'world' 'this' 'is' 'st/x').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
     b open
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
    "Created: 28.2.1996 / 15:13:46 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    "Modified: 28.2.1996 / 15:18:40 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   469
!ComboListView methodsFor:'private'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   470
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   471
getValueFromModel
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   472
    |selection idx aspect|
278
4a22889a5730 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
   473
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   474
    (model notNil and:[aspectMsg notNil]) ifTrue:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   475
	"/ kludge - try #value if aspect is the default and
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   476
	"/ not understood by the model
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   477
	"/ this allows a valueHolder to be used, even
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   478
	"/ if the aspectMessage was not setup correctly.
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   479
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   480
	aspect := aspectMsg.
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   481
	aspect == self class defaultAspectMessage ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   482
	    (model respondsTo:aspect) ifFalse:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   483
		aspect := #value
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   484
	    ]
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   485
	].
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   486
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   487
	selection := model perform:aspect.
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   488
	selection notNil ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   489
	    values notNil ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   490
		idx := values indexOf:selection
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   491
	    ] ifFalse:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   492
		useIndex ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   493
		    idx := selection
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   494
		] ifFalse:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   495
		    self contents:selection.
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   496
		    ^ self.
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   497
		]
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   498
	    ].
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   499
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   500
	    self contents:(list at:idx ifAbsent:nil)
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   501
	]
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   502
    ].
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   503
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   504
    "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
   505
    "Modified: 28.2.1997 / 13:41:02 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   506
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   507
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   508
!ComboListView methodsFor:'queries'!
65229309ad5e specClass
ca
parents: 283
diff changeset
   509
65229309ad5e specClass
ca
parents: 283
diff changeset
   510
specClass
598
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   511
    "XXX no longer needed (inherited default works here)"
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   512
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   513
    self class == ComboListView ifTrue:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   514
	^ ComboListSpec
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   515
    ].
301
edddd206a2e5 specClass query
ca
parents: 293
diff changeset
   516
    ^ super specClass
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   517
598
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   518
    "Modified: / 31.10.1997 / 19:49:34 / cg"
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   519
! !
65229309ad5e specClass
ca
parents: 283
diff changeset
   520
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
!ComboListView methodsFor:'user interaction'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   523
select:anIndex
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   524
    "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
   525
368
c99ef22c72f8 removed unused variable
Claus Gittinger <cg@exept.de>
parents: 332
diff changeset
   526
    |label value chg|
238
6be113228de3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 232
diff changeset
   527
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   528
    values isNil ifTrue:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   529
	value := anIndex.
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   530
	useIndex ifFalse:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   531
	    value := list at:anIndex.
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   532
	]
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   533
    ] ifFalse:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   534
	value := values at:anIndex
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   535
    ].
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   536
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   537
    label := list at:anIndex.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   538
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   539
    field label:label.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   540
293
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   541
    "
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   542
     ST-80 style model notification ...
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   543
     this updates the model (typically, a ValueHolder)
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   544
    "
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   545
    (model notNil and:[changeMsg notNil]) ifTrue:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   546
	"/ kludge - try #value: if changeMsg is the default and
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   547
	"/ not understood by the model
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   548
	"/ this allows a valueHolder to be used, even
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   549
	"/ if the aspectMessage was not setup correctly.
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   550
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   551
	chg := changeMsg.
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   552
	chg == self class defaultChangeMessage ifTrue:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   553
	    (model respondsTo:chg) ifFalse:[
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   554
		chg := #value:
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   555
	    ]
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   556
	].
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   557
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   558
	self sendChangeMessage:chg with:value
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   559
    ].
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
    pullDownButton turnOff.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
293
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   562
    "
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   563
     ST/X style actionBlock evaluation ...
e707cc62ee30 first tell model - then evaluate action block.
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   564
    "
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   565
    action notNil ifTrue:[
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   566
	action value:value
283
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   567
    ].
7441b4d65776 additional action hook - evaluated when selection changes
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
   568
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   569
    "Created: 27.2.1997 / 15:18:44 / cg"
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   570
    "Modified: 28.2.1997 / 13:50:17 / cg"
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
270
35558a88d500 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   573
!ComboListView class methodsFor:'documentation'!
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
version
679
bd0e422aab67 fixed model setting & useIndex: handling (aspect)
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   576
    ^ '$Header: /cvs/stx/stx/libwidg2/ComboListView.st,v 1.26 1998-01-25 14:14:42 cg Exp $'
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
! !