PopUpList.st
author Claus Gittinger <cg@exept.de>
Tue, 27 Feb 1996 14:51:16 +0100
changeset 417 3f48ca2beb7d
parent 327 5cd2a6f4f28e
child 585 8f395aba0173
permissions -rw-r--r--
use device shiftDown - NOT sensor shiftDown
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     1
"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     4
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    11
"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    12
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    13
Button subclass:#PopUpList
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    14
	instanceVariableNames:'menu menuAction values useIndex listMsg'
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    15
	classVariableNames:''
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    16
	poolDictionaries:''
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    17
	category:'Views-Interactors'
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    18
!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
    19
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    20
!PopUpList class methodsFor:'documentation'!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    21
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    22
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    23
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    25
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    26
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    27
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    28
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    30
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    31
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    32
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    33
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    34
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    35
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    36
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    37
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    38
    a PopUpList is basically a button with a popup menu.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    39
    The PopUpLists label is showing the current selection from the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    40
    list.
121
claus
parents: 120
diff changeset
    41
    When an entry is selected, an actionBlock (if nonNil) is evaluated
claus
parents: 120
diff changeset
    42
    and (if nonNil), the model is notified via the changeMessage.
125
claus
parents: 121
diff changeset
    43
121
claus
parents: 120
diff changeset
    44
    The default changeMessage used is #selection:, which allows a
claus
parents: 120
diff changeset
    45
    PopUpList to be used with a SelectionInList as model.
claus
parents: 120
diff changeset
    46
    (if used with some other model, either use an adaptor, or set the
125
claus
parents: 121
diff changeset
    47
     changeMessage to something else ..)
claus
parents: 121
diff changeset
    48
claus
parents: 121
diff changeset
    49
    Instance variables:
claus
parents: 121
diff changeset
    50
claus
parents: 121
diff changeset
    51
	menu                            helpers for the popup menu
claus
parents: 121
diff changeset
    52
	menuAction 
claus
parents: 121
diff changeset
    53
	values 
claus
parents: 121
diff changeset
    54
claus
parents: 121
diff changeset
    55
	useIndex             <Boolean>  if true, the index of the selected entry
claus
parents: 121
diff changeset
    56
					is passed to the action block and the
claus
parents: 121
diff changeset
    57
					model in a change-message.
claus
parents: 121
diff changeset
    58
					If false (the default), the value is passed.
claus
parents: 121
diff changeset
    59
					Notice that the default changeMessage is
claus
parents: 121
diff changeset
    60
					#selection:, which is not ok to be used
claus
parents: 121
diff changeset
    61
					with useIndex:true and a selectionInList model.
claus
parents: 121
diff changeset
    62
					(set the changeMessage to #selectionIndex: then)
claus
parents: 121
diff changeset
    63
claus
parents: 121
diff changeset
    64
	listMsg              <Symbol>   message to aquire a new list from the
claus
parents: 121
diff changeset
    65
					model. Default is #list.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    66
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    67
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    68
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    69
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    70
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    71
    example use:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    72
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    73
     |p|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    74
     p := PopUpList label:'healthy fruit'.
119
claus
parents: 105
diff changeset
    75
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    76
     p open
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    77
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    78
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    79
    with an initial selection:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    80
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    81
     |p|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    82
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
    83
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    84
     p selection:'apples'.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    85
     p open
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    86
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    87
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    88
    with separating lines:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    89
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    90
     |p|
119
claus
parents: 105
diff changeset
    91
     p := PopUpList label:'fruit'.
claus
parents: 105
diff changeset
    92
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    93
     p selection:'apples'.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
    94
     p open
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    95
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    96
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    97
    with an action:
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    98
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    99
     |p|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   100
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
   101
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   102
     p selection:'apples'.
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   103
     p action:[:what | Transcript showCr:'you selected: ' , what].
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   104
     p open
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   105
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   106
119
claus
parents: 105
diff changeset
   107
    sometimes, you may like the index instead of the value:
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   108
    (notice, that the separating line counts, so you have to take care ...)
119
claus
parents: 105
diff changeset
   109
claus
parents: 105
diff changeset
   110
     |p|
claus
parents: 105
diff changeset
   111
     p := PopUpList label:'dummy'.
claus
parents: 105
diff changeset
   112
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
claus
parents: 105
diff changeset
   113
     p selection:'apples'.
claus
parents: 105
diff changeset
   114
     p action:[:what | Transcript show:'you selected: '; showCr:what].
claus
parents: 105
diff changeset
   115
     p useIndex:true.
claus
parents: 105
diff changeset
   116
     p open
claus
parents: 105
diff changeset
   117
claus
parents: 105
diff changeset
   118
claus
parents: 105
diff changeset
   119
    since the list is actually a popupMenu, you can add double-separators:
claus
parents: 105
diff changeset
   120
claus
parents: 105
diff changeset
   121
     |p|
claus
parents: 105
diff changeset
   122
     p := PopUpList label:'dummy'.
claus
parents: 105
diff changeset
   123
     p list:#('apples' 'bananas' 'grape' 'lemon' 
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   124
              '=' 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   125
              'margaritas' 'pina colada'
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   126
              '=' 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   127
              'smalltalk' 'c++' 'eiffel' 'java').
119
claus
parents: 105
diff changeset
   128
     p values:#(apples bananas grape lemon 
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   129
                nil 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   130
                'mhmh - so good' 'makes headache'
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   131
                nil
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   132
                'great' 'another headache' 'not bad' 'neat').
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   133
     p selection:'apples'.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   134
     p action:[:what | Transcript show:'you selected: '; showCr:what].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   135
     p open
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   136
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   137
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   138
    since the list is actually represented by a menuView,
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   139
    which itself is inheriting from listView, which itself can display
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   140
    things different from strings, arbitrary lists can be constructed:
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   141
    (see ListEntry classes)
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   142
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   143
     |p l|
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   144
     p := PopUpList label:'dummy'.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   145
     l := OrderedCollection new.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   146
     l add:(ColoredListEntry string:'apples' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   147
     l add:(ColoredListEntry string:'bananas' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   148
     l add:(ColoredListEntry string:'grape' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   149
     l add:(ColoredListEntry string:'lemon' color:Color red).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   150
     l add:'='.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   151
     l add:(ColoredListEntry string:'margaritas' color:Color green darkened darkened).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   152
     l add:(ColoredListEntry string:'pina colada' color:Color green darkened darkened).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   153
     l add:'='.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   154
     l add:(ColoredListEntry string:'smalltalk' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   155
     l add:(ColoredListEntry string:'c++' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   156
     l add:(ColoredListEntry string:'eiffel' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   157
     l add:(ColoredListEntry string:'java' color:Color blue).
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   158
     p list:l.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   159
     p values:#(apples bananas grape lemon 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   160
                nil 
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   161
                'mhmh - so good' 'makes headache'
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   162
                nil
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   163
                'great' 'another headache' 'not bad' 'neat').
119
claus
parents: 105
diff changeset
   164
     p selection:'apples'.
claus
parents: 105
diff changeset
   165
     p action:[:what | Transcript show:'you selected: '; showCr:what].
claus
parents: 105
diff changeset
   166
     p open
claus
parents: 105
diff changeset
   167
claus
parents: 105
diff changeset
   168
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   169
    with values different from the label strings:
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   170
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   171
     |p|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   172
     p := PopUpList label:'dummy'.
119
claus
parents: 105
diff changeset
   173
     p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   174
     p selection:'apples'.
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   175
     p values:#(10 20 30 40 nil 50).
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   176
     p action:[:what | Transcript show:'you selected: '; showCr:what].
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   177
     p open
119
claus
parents: 105
diff changeset
   178
121
claus
parents: 120
diff changeset
   179
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   180
    with a model (see in the inspector, how the valueHolders index-value changes):
119
claus
parents: 105
diff changeset
   181
claus
parents: 105
diff changeset
   182
     |p model|
claus
parents: 105
diff changeset
   183
claus
parents: 105
diff changeset
   184
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
claus
parents: 105
diff changeset
   185
claus
parents: 105
diff changeset
   186
     p := PopUpList label:'healthy fruit'.
claus
parents: 105
diff changeset
   187
     p model:model.
claus
parents: 105
diff changeset
   188
     p open.
121
claus
parents: 120
diff changeset
   189
     model selectionIndexHolder inspect
claus
parents: 120
diff changeset
   190
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   191
125
claus
parents: 121
diff changeset
   192
    a popupList and a SelectionInListView on the same model:
claus
parents: 121
diff changeset
   193
claus
parents: 121
diff changeset
   194
     |p slv model|
claus
parents: 121
diff changeset
   195
claus
parents: 121
diff changeset
   196
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
claus
parents: 121
diff changeset
   197
     model selection:'apples'.
claus
parents: 121
diff changeset
   198
claus
parents: 121
diff changeset
   199
     p := PopUpList on:model.
126
claus
parents: 125
diff changeset
   200
     p useIndex:true; aspect:#selectionIndex; change:#selectionIndex:.
125
claus
parents: 121
diff changeset
   201
     p open.
claus
parents: 121
diff changeset
   202
claus
parents: 121
diff changeset
   203
     slv := SelectionInListView on:model.
claus
parents: 121
diff changeset
   204
     slv open.
claus
parents: 121
diff changeset
   205
126
claus
parents: 125
diff changeset
   206
     p inspect.
125
claus
parents: 121
diff changeset
   207
     model selectionIndexHolder inspect
claus
parents: 121
diff changeset
   208
claus
parents: 121
diff changeset
   209
127
claus
parents: 126
diff changeset
   210
    two PopUpLists on the same model, different aspects:
121
claus
parents: 120
diff changeset
   211
claus
parents: 120
diff changeset
   212
     |top panel p model|
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   213
121
claus
parents: 120
diff changeset
   214
     model := Plug new.
claus
parents: 120
diff changeset
   215
     model respondTo:#eat: with:[:val | Transcript showCr:'eat: ' , val].
claus
parents: 120
diff changeset
   216
     model respondTo:#drink: with:[:val | Transcript showCr:'drink: ' , val].
claus
parents: 120
diff changeset
   217
     model respondTo:#meals with:[#(taco burrito enchilada)].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   218
     model respondTo:#drinks with:[#(margarita water corona)].
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   219
121
claus
parents: 120
diff changeset
   220
     top := StandardSystemView new.
claus
parents: 120
diff changeset
   221
     top extent:(100@100).
claus
parents: 120
diff changeset
   222
     panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
claus
parents: 120
diff changeset
   223
     panel horizontalLayout:#fitSpace.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   224
121
claus
parents: 120
diff changeset
   225
     p := PopUpList label:'meals'.
126
claus
parents: 125
diff changeset
   226
     p model:model; listMessage:#meals; aspect:nil; change:#eat:.
121
claus
parents: 120
diff changeset
   227
     panel add:p.
119
claus
parents: 105
diff changeset
   228
121
claus
parents: 120
diff changeset
   229
     p := PopUpList label:'drinks'.
126
claus
parents: 125
diff changeset
   230
     p model:model; listMessage:#drinks; aspect:nil; change:#drink:.
121
claus
parents: 120
diff changeset
   231
     panel add:p.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   232
121
claus
parents: 120
diff changeset
   233
     top open
claus
parents: 120
diff changeset
   234
"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   235
! !
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   236
125
claus
parents: 121
diff changeset
   237
!PopUpList class methodsFor:'defaults'!
claus
parents: 121
diff changeset
   238
claus
parents: 121
diff changeset
   239
defaultAspectMessage
claus
parents: 121
diff changeset
   240
    ^ #selection
claus
parents: 121
diff changeset
   241
!
claus
parents: 121
diff changeset
   242
claus
parents: 121
diff changeset
   243
defaultChangeMessage
claus
parents: 121
diff changeset
   244
    ^ #selection:
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   245
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   246
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   247
defaultListMessage
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   248
    ^ #list 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   249
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   250
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   251
!PopUpList methodsFor:'accessing'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   252
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   253
action:aOneArgBlock
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   254
    "set the action to be performed on selection changes;
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   255
     the argument, aOneArgBlock will be evaluated with the
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   256
     selection-value as argument"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   257
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   258
    menuAction := aOneArgBlock
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   259
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   260
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   261
contents
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
    ^ self label
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   264
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   265
contents:con
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   266
    ^ self selection:con
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   267
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   268
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   269
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   270
list
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   271
    "return the list - i.e. the values shown in the pop-up list"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   272
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   273
    ^ menu labels
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   274
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   275
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   276
list:aList
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   277
    "set the list - i.e. the values shown in the pop-up list"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   278
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   279
    self createMenuFor:aList.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   280
    realized ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   281
	self computeLabelSize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   282
    ]
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   283
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   284
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   285
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   286
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   287
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   288
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   289
     p open
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   290
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   291
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   292
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   293
selection:indexOrString
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   294
    "set (force) a selection - usually done to set
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   295
     an initial selection without updating others"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   296
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   297
    |index wasFix|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   298
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   299
    index := menu indexOf:indexOrString.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   300
    index == 0 ifTrue:[^ self].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   301
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   302
    "kludge: dont want label to resize ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   303
    wasFix := fixSize. fixSize := true.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   304
    self label:(menu labels at:index) printString.
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   305
    fixSize := wasFix
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   306
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   307
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   308
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   309
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   310
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   311
     p selection:'grape'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   312
     p open 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   313
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   314
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   315
     p := PopUpList label:'what fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   316
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   317
     p selection:'blabla'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   318
     p open
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   319
    "
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   320
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   321
    "Modified: 8.2.1996 / 12:55:01 / cg"
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   322
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   323
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   324
useIndex:aBoolean 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   325
    "tell the popuplist to pass the index (instead of the value)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   326
     to both the actionBlock and model. Notice, that if you use a model,
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   327
     the default changeSelector is not ok for using index and a SelectionInList"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   328
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   329
    useIndex := aBoolean
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   330
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   331
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   332
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   333
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   334
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   335
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   336
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   337
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   338
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   339
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   340
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   341
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   342
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   343
     p useIndex:true.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   344
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   345
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   346
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   347
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   348
values:aList
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   349
    "set a value list - these are reported via the action or changeSymbol instead of
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   350
     the labe strings."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   351
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   352
    values := aList.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   353
    menu args:(1 to:aList size).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   354
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   355
    "
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   356
     |p|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   357
     p := PopUpList label:'fruit ?'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   358
     p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   359
     p values:#(1 2 3 4 'mhmh - good').
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   360
     p action:[:val | Transcript showCr:'selected: ' , val printString].   
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   361
     p open.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   362
    "
125
claus
parents: 121
diff changeset
   363
! !
claus
parents: 121
diff changeset
   364
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   365
!PopUpList methodsFor:'accessing-mvc'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   366
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   367
addModelInterfaceTo:aDictionary
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   368
    "see comment in View>>modelInterface"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   369
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   370
    super addModelInterfaceTo:aDictionary.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   371
    aDictionary at:#listMessage put:listMsg
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   372
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   373
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   374
getListFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   375
    "if I have a model and a listMsg, get my list from it"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   376
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   377
    (model notNil 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   378
    and:[listMsg notNil]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   379
	self list:(model perform:listMsg).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   380
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   381
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   382
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   383
getSelectionFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   384
    "if I have a model and an aspectMsg, get my current value from it"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   385
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   386
    (model notNil 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   387
    and:[aspectMsg notNil]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   388
	menu isNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   389
	    self getListFromModel
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   390
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   391
	self selection:(model perform:aspectMsg).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   392
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   393
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   394
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   395
listMessage
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   396
    "return the selector by which we ask the model for the list.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   397
     Default is #list."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   398
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   399
    ^ listMsg
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   400
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   401
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   402
listMessage:aSelector
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   403
    "set the selector by which we ask the model for the list.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   404
     Default is #list."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   405
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   406
    listMsg := aSelector
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   407
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   408
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   409
!PopUpList methodsFor:'change & update'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   410
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   411
update:something with:aParameter from:changedObject
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   412
    changedObject == model ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   413
	(something == aspectMsg 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   414
	or:[something == #selectionIndex]) ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   415
	    self getSelectionFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   416
	    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   417
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   418
	something == listMsg ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   419
	    self getListFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   420
	].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   421
	^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   422
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   423
    super update:something with:aParameter from:changedObject
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   424
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   425
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   426
!PopUpList methodsFor:'drawing'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   427
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   428
drawWith:fgColor and:bgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   429
    |mmH mmV mW mH|
136
claus
parents: 135
diff changeset
   430
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   431
    controller pressed ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   432
	super drawWith:enteredFgColor and:enteredBgColor
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   433
    ] ifFalse:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   434
	super drawWith:fgColor and:bgColor.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   435
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   436
    mmH := device horizontalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   437
    mmV := device verticalPixelPerMillimeter rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   438
    mW := (device horizontalPixelPerMillimeter * 2.5) rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   439
    mH := (device verticalPixelPerMillimeter * 1.5) rounded.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   440
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   441
    self drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV // 2)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   442
		 width:mW height:mH level:2
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   443
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   444
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   445
showActive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   446
    "no need to redraw - will pop menu ontop of me anyway ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   447
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   448
    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   449
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   450
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   451
showPassive
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   452
    "no need to redraw - will redraw from unpopped menu anyway ..."
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   453
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   454
    ^ self
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   456
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   457
!PopUpList methodsFor:'event handling'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   458
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   459
popMenu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   460
    |org mv w|
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   461
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   462
    menu notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   463
	self turnOffWithoutRedraw. 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   464
	menu font:font.
136
claus
parents: 135
diff changeset
   465
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   467
	 adjust the menus width to my current width
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   468
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   469
	mv := menu menuView.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   470
	mv create.      "/ stupid: it resizes itself upon first create
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   471
	w := mv width.  "/ to its preferred size.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   472
	w := w max:(self width - (2 * menu margin) - (menu borderWidth*2)).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   473
	mv width:w.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   474
	mv level:0; borderWidth:0.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   475
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   476
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   477
	 the popupMenu wants Display coordinates in its showAt: method
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   478
	"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   479
	org := device translatePoint:0@0 
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   480
				from:(self id)
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   481
				  to:(DisplayRootView new id).
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   482
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   483
	menu showAt:org "resizing:false"
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   484
    ].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   485
! !
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   486
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   487
!PopUpList methodsFor:'initialization'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   488
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   489
defaultControllerClass
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   490
    ^ PopUpListController
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   491
!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   492
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   493
initialize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   494
    super initialize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   495
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   496
    controller beTriggerOnDown.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   497
    controller action:[self popMenu].
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   498
    self adjust:#left.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   499
    useIndex := false.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   500
    self label:'popup'.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   501
    listMsg := self class defaultListMessage.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   502
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   503
    onLevel := offLevel.
136
claus
parents: 135
diff changeset
   504
! !
claus
parents: 135
diff changeset
   505
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   506
!PopUpList methodsFor:'private'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   507
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   508
computeLabelSize
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   509
    "compute the extent needed to hold the label plus the mark"
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   510
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   511
    |mmH mmV savedLogo longest longestWidth|
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   512
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   513
    menu isNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   514
        super computeLabelSize
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   515
    ] ifFalse:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   516
        "hack: simulate logo change to longest menu entry"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   517
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   518
        font := font on:device.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   519
        longest := logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   520
        longestWidth := font widthOf:logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   521
        menu labels do:[:entry |
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   522
            |this|
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   523
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   524
            this := font widthOf:entry printString.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   525
            this > longestWidth ifTrue:[
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   526
                longest := entry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   527
                longestWidth := this
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   528
            ].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   529
        ].
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   530
        savedLogo := logo.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   531
        logo := longest printString.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   532
        super computeLabelSize.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   533
        logo := savedLogo.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 20
diff changeset
   534
"self halt.     "
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   535
    ].
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   536
    mmH := device horizontalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   537
    mmV := device verticalPixelPerMillimeter.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   538
    labelWidth := labelWidth + hSpace + (mmH * 2.5) rounded + hSpace.
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   539
    labelHeight := labelHeight max: (mmV * 2) rounded
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   540
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   541
    "Modified: 8.2.1996 / 13:00:33 / cg"
121
claus
parents: 120
diff changeset
   542
!
claus
parents: 120
diff changeset
   543
claus
parents: 120
diff changeset
   544
createMenuFor:aList
claus
parents: 120
diff changeset
   545
    menu := PopUpMenu
claus
parents: 120
diff changeset
   546
		  labels:aList
claus
parents: 120
diff changeset
   547
	       selectors:#select:
claus
parents: 120
diff changeset
   548
		    args:(1 to:aList size) 
claus
parents: 120
diff changeset
   549
		receiver:self
claus
parents: 120
diff changeset
   550
		     for:self.
128
claus
parents: 127
diff changeset
   551
!
claus
parents: 127
diff changeset
   552
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   553
realize
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   554
    super realize.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   555
    model notNil ifTrue:[
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   556
	self getListFromModel.
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   557
	self getSelectionFromModel.
121
claus
parents: 120
diff changeset
   558
    ].
claus
parents: 120
diff changeset
   559
! !
claus
parents: 120
diff changeset
   560
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   561
!PopUpList methodsFor:'private-controller access'!
121
claus
parents: 120
diff changeset
   562
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   563
menu
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   564
    "return the menu component"
125
claus
parents: 121
diff changeset
   565
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   566
    ^ menu
126
claus
parents: 125
diff changeset
   567
! !
claus
parents: 125
diff changeset
   568
136
claus
parents: 135
diff changeset
   569
!PopUpList methodsFor:'queries'!
claus
parents: 135
diff changeset
   570
claus
parents: 135
diff changeset
   571
preferredExtent
claus
parents: 135
diff changeset
   572
    "redefined to make certain that the menu is fully defined"
claus
parents: 135
diff changeset
   573
claus
parents: 135
diff changeset
   574
    menu isNil ifTrue:[
claus
parents: 135
diff changeset
   575
	self getListFromModel
claus
parents: 135
diff changeset
   576
    ].
claus
parents: 135
diff changeset
   577
    self computeLabelSize.
claus
parents: 135
diff changeset
   578
    ^ super preferredExtent.
155
claus
parents: 136
diff changeset
   579
!
claus
parents: 136
diff changeset
   580
claus
parents: 136
diff changeset
   581
specClass
claus
parents: 136
diff changeset
   582
    self class == PopUpList ifTrue:[^ PopUpListSpec].
claus
parents: 136
diff changeset
   583
    ^ nil
136
claus
parents: 135
diff changeset
   584
! !
claus
parents: 135
diff changeset
   585
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   586
!PopUpList methodsFor:'user actions'!
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   587
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   588
select:anEntry
119
claus
parents: 105
diff changeset
   589
    "this is sent from the popupmenu when an entry was selected"
claus
parents: 105
diff changeset
   590
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   591
    |value label|
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   592
119
claus
parents: 105
diff changeset
   593
    label := menu labels at:anEntry.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   594
    values isNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   595
        value := anEntry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   596
        useIndex ifFalse:[
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   597
            value := menu labels at:anEntry.
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   598
        ]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   599
    ] ifFalse:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   600
        value := values at:anEntry
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   601
    ].
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   602
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   603
    menuAction notNil ifTrue:[
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   604
        menuAction value:value.
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   605
    ].
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   606
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   607
    self sizeFixed:true.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   608
    self label:label printString.
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   609
119
claus
parents: 105
diff changeset
   610
    "
121
claus
parents: 120
diff changeset
   611
     tell my model - if any
119
claus
parents: 105
diff changeset
   612
    "
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   613
    self sendChangeMessageWith:value
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   614
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   615
    "Modified: 8.2.1996 / 11:58:51 / cg"
20
0d9c61aacaa4 Initial revision
claus
parents:
diff changeset
   616
! !
121
claus
parents: 120
diff changeset
   617
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   618
!PopUpList class methodsFor:'documentation'!
121
claus
parents: 120
diff changeset
   619
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   620
version
327
5cd2a6f4f28e fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   621
    ^ '$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.21 1996-02-08 14:08:35 cg Exp $'
121
claus
parents: 120
diff changeset
   622
! !