ComboListView.st
author Stefan Vogel <sv@exept.de>
Fri, 18 Jul 2008 10:56:52 +0200
changeset 3480 5178cda62a25
parent 3463 2f56e8ccb3f8
child 4165 042f65590cc8
permissions -rw-r--r--
changed #initialize - set font
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1302
30c3d98bc450 Fix typo
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
     1
"
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
     2
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
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
"
1826
080df5e45c3c examples
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
080df5e45c3c examples
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
    13
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ComboView subclass:#ComboListView
3080
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
    15
	instanceVariableNames:'useIndex values selectCondition'
1729
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
    16
	classVariableNames:''
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
    17
	poolDictionaries:''
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
    18
	category:'Views-Interactors'
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
270
35558a88d500 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    21
!ComboListView class methodsFor:'documentation'!
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    23
copyright
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    24
"
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    25
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
    26
              All Rights Reserved
332
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    27
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    28
 This software is furnished under a license and may be used
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    29
 only in accordance with the terms of that license and with the
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    31
 be provided or otherwise made available to, or used by, any
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    32
 other person.  No title to or ownership of the software is
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    33
 hereby transferred.
78dcd3cacbfd documentation
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    34
"
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
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    A ComboListView combines an label with a drop down list of default inputs;
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    choosing any from the pulled list sets the string in the label.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    This is the same as a PopUpList or SelectionInListView, bit looks different.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    46
    The preferred model is a SelectionInList, but a simple valueHolder
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    47
    may also be used. 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    48
    If some other model is to be used, the changeMessage and aspectMessage 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    49
    should be defined as appropriate (or an aspectAdaptor should be used).
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    50
    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
    51
    items in the popped menu; 
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    52
    otherwise, if listMessage is nonNil, the model is assumed to also provide the
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    53
    list as displayed in the popped menu.
275
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    54
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    55
    [author:]
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    56
        Claus Gittinger
275
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    57
da88b7732dff commentary
Claus Gittinger <cg@exept.de>
parents: 272
diff changeset
    58
    [see also:]
1281
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    59
        ComboView
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    60
        PopUpList SelectionInListView
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    61
        ComboBoxView ExtendedComboBox
94b22cb9c19f documentation
Claus Gittinger <cg@exept.de>
parents: 1206
diff changeset
    62
        PullDownMenu Label EntryField
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
"
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
examples
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
"
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    68
  non-MVC use; 
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
    69
    set the list explicitely:
1826
080df5e45c3c examples
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
    70
                                                                [exBegin]
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    71
     |top comboList|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    72
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    73
     top := StandardSystemView new.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    74
     top extent:(300 @ 200).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    75
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    76
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    77
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    78
     comboList bottomInset:(comboList preferredExtent y negated).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    79
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    80
     comboList list:#('hello' 'world' 'this' 'is' 'st/x').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    81
     top open.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    82
                                                                [exEnd]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    83
2825
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    84
  a really, really long list (notice scrollup/down buttons at the top/bottom); 
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    85
                                                                [exBegin]
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    86
     |top comboList|
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    87
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    88
     top := StandardSystemView new.
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    89
     top extent:(300 @ 200).
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    90
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    91
     comboList := ComboListView in:top.
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    92
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    93
     comboList bottomInset:(comboList preferredExtent y negated).
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    94
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    95
     comboList list:((1 to:100) collect:[:n | n printString]).
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    96
     top open.
b27f9e7776d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1826
diff changeset
    97
                                                                [exEnd]
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    98
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
    99
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   100
    with callBack:
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   101
                                                                [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   102
     |top comboList|
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
     top := StandardSystemView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
     top extent:(300 @ 200).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   107
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   108
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   109
     comboList bottomInset:(comboList preferredExtent y negated).
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   111
     comboList list:#('hello' 'world' 'this' 'is' 'st/x').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   112
     comboList action:[:selected | Transcript showCR:selected].
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
     top open.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   114
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   118
    with separating lines:
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   119
                                                                [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   120
     |top comboList|
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   121
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   122
     top := StandardSystemView label:'fruit chooser'.
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   123
     top extent:(300 @ 200).
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   124
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   125
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   126
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   127
     comboList bottomInset:(comboList preferredExtent y negated).
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   128
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   129
     comboList label:'fruit'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   130
     comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   131
     comboList action:[:selected | Transcript showCR:selected].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   132
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   133
                                                                [exEnd]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   134
305
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   135
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   136
7dd100869f7b cleaned up model interface
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
   137
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   138
    with values different from the label strings:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   139
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   140
     |top comboList|
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   141
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   142
     top := StandardSystemView label:'fruit chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   143
     top extent:(300 @ 200).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   144
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   145
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   146
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   147
     comboList bottomInset:(comboList preferredExtent y negated).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   148
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   149
     comboList label:'dummy'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   150
     comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   151
     comboList selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   152
     comboList values:#(10 20 30 40 nil 50).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   153
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   154
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   155
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   156
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   157
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   158
    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
   159
    (notice, that the separating line counts, so you have to take care ...)
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   160
                                                                [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   161
     |top comboList|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   162
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   163
     top := StandardSystemView label:'fruit chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   164
     top extent:(300 @ 200).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   165
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   166
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   167
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   168
     comboList bottomInset:(comboList preferredExtent y negated).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   169
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   170
     comboList label:'dummy'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   171
     comboList list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   172
     comboList selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   173
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   174
     comboList useIndex:true.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   175
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   176
                                                                [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   177
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   178
    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
   179
    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
   180
    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
   181
    (see ListEntry, LabelAndIcon and Text classes)
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   182
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   183
     |top comboList l|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   184
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   185
     top := StandardSystemView label:'fruit chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   186
     top extent:(300 @ 200).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   187
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   188
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   189
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   190
     comboList bottomInset:(comboList preferredExtent y negated).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   191
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   192
     l := OrderedCollection new.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   193
     l add:(Text string:'apples' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   194
     l add:(Text string:'bananas' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   195
     l add:(Text string:'grape' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   196
     l add:(Text string:'lemon' color:Color red).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   197
     l add:'='.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   198
     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
   199
     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
   200
     l add:'='.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   201
     l add:(Text string:'smalltalk' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   202
     l add:(Text string:'c++' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   203
     l add:(Text string:'eiffel' color:Color blue).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   204
     l add:(Text string:'java' color:Color blue).
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   205
     comboList list:l.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   206
     comboList values:#(apples bananas grape lemon 
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   207
                nil 
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   208
                'mhmh - so good' 'makes headache'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   209
                nil
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   210
                'great' 'another headache' 'not bad' 'neat').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   211
     comboList selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   212
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   213
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   214
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   215
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   216
    with values different from the label strings:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   217
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   218
     |top comboList|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   219
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   220
     top := StandardSystemView label:'language chooser'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   221
     top extent:(300 @ 200).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   222
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   223
     comboList := ComboListView in:top.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   224
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   225
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   226
     comboList list:( #(
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   227
                'usa'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   228
                'uk'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   229
                'france'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   230
                'germany'       
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   231
                'italy'
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   232
               ) collect:[:country |
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   233
                            LabelAndIcon 
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   234
                                icon:(Image fromFile:'bitmaps/xpmBitmaps/countries/' , country , '.xpm')
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   235
                                string:country
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   236
                         ]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   237
            ).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   238
     comboList values:#(us england france germany italy).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   239
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   240
     comboList action:[:what | Transcript show:'you selected: '; showCR:what].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   241
     comboList bottomInset:(comboList preferredExtent y negated).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   242
     top open
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   243
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   244
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   245
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   246
  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
   247
  the defaults are setup to allow a SelectionInList directly as model:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   248
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   249
     |p model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   250
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   251
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   252
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   253
     p := ComboListView label:'healthy fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   254
     p model:model.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   255
     p openAt:(Screen current center).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   256
     model inspect
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   257
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   258
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   259
  model provides selection; list is explicit:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   260
                                                                [exBegin]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
     |model top b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
     model := 'foo' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
     top := StandardSystemView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
     top extent:(300 @ 200).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
     b := ComboListView in:top.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
     b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
     b bottomInset:(b preferredExtent y negated).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
     b list:#('hello' 'world' 'this' 'is' 'st/x').
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   273
     b model:model.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
     top openModal.
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   276
     Transcript showCR:('comboBox''s value: ' , model value).
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   277
                                                                [exEnd]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   280
    a comboListView and a SelectionInListView on the same model:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   281
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   282
     |p slv model|
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
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   285
     model selection:'apples'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   286
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   287
     p := ComboListView on:model.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   288
     p openAt:(Screen current center).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   289
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   290
     slv := SelectionInListView on:model.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   291
     slv openAt:(Screen current center + (100@100)).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   292
                                                                        [exEnd]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   293
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   294
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   295
    like above, using index:
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   296
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   297
     |p slv model|
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   298
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   299
     model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas').
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   300
     model selection:'apples'.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   301
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   302
     p := ComboListView on:model.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   303
     p openAt:(Screen current center).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   304
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   305
     slv := SelectionInListView on:model.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   306
     slv openAt:(Screen current center + (100@100)).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   307
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   308
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   309
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   310
    two comboListViews on the same model, different aspects:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   311
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   312
     |top panel p model|
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   313
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   314
     model := Plug new.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   315
     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
   316
     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
   317
     model respondTo:#meals with:[#(taco burrito enchilada)].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   318
     model respondTo:#drinks with:[#(margarita water corona)].
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   319
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   320
     top := StandardSystemView label:'meal chooser'.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   321
     top extent:(150@150).
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   322
     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
   323
     panel horizontalLayout:#fitSpace.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   324
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   325
     p := ComboListView label:'meals'.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   326
     p aspect:nil; model:model; listMessage:#meals; change:#eat:.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   327
     panel add:p.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   328
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   329
     p := ComboListView label:'drinks'.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   330
     p aspect:nil; model:model; listMessage:#drinks; change:#drink:.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   331
     panel add:p.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   332
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   333
     top open
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   334
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   335
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   336
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   337
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   338
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   339
    with separate list- and indexHolders:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   340
                                                                        [exBegin]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   341
     |p selectionHolder listHolder|
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
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   344
     selectionHolder := 'apples' asValue.
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
     p := ComboListView label:'healthy fruit'.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   347
     p listHolder:listHolder.
310
15ef4f52f8cf comments
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   348
     p model:selectionHolder.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   349
     p openAt:(Screen current center).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   350
     selectionHolder inspect
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   351
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   352
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   353
    using different values:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   354
                                                                        [exBegin]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   355
     |p priceHolder listHolder prices priceField|
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   356
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   357
     listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   358
     prices := #(10 10 5 15 50).
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   359
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   360
     priceHolder := nil asValue.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   361
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   362
     p := ComboListView new.
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   363
     p listHolder:listHolder.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   364
     p model:priceHolder.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   365
     p values:prices.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   366
     p openAt:(Screen current center).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   367
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   368
     priceField := EditField new.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   369
     priceField readOnly:true.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   370
     priceField model:(TypeConverter onNumberValue:priceHolder).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   371
     priceField openAt:(Screen current center + (10@10)).
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   372
                                                                        [exEnd]
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   373
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   374
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
  in a dialog:
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   376
                                                                [exBegin]
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
     |model1 model2 dialog b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
     model1 := 'foo' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
     model2 := 'bar' asValue.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
     dialog := Dialog new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
     (dialog addTextLabel:'ComboList example:') adjust:#left.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
     (b := dialog addComboListOn:model1 tabable:true).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
     b list:#('fee' 'foe' 'foo').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
     (b := dialog addComboListOn:model2 tabable:true).
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
     b list:#('bar' 'baz' 'baloo').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
     dialog addVerticalSpace.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
     dialog addOkButton.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
     dialog open.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
184
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   398
     Transcript showCR:('1st comboBox''s value: ' , model1 value).
13a2f3677c68 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   399
     Transcript showCR:('2nd comboBox''s value: ' , model2 value).
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   400
                                                                [exEnd]
3080
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   401
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   402
  Select condition
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   403
                                                                [exBegin]
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   404
     |top comboList|
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   405
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   406
     top := StandardSystemView new.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   407
     top extent:(300 @ 200).
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   408
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   409
     comboList := ComboListView in:top.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   410
     comboList origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   411
     comboList bottomInset:(comboList preferredExtent y negated).
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   412
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   413
     comboList list:((1 to:100) collect:[:n | n printString]).
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   414
     comboList selectCondition:[:newValue | (Number readFrom:newValue) even].
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   415
     top open.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   416
                                                                [exEnd]
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   417
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   418
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   419
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   423
!ComboListView class methodsFor:'defaults'!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   424
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   425
defaultAspectMessage
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   426
    ^ #selection
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   427
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   428
    "Created: 27.2.1997 / 15:23:13 / cg"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   429
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   430
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   431
defaultChangeMessage
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   432
    ^ #selection:
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   433
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   434
    "Created: 27.2.1997 / 15:23:18 / cg"
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
3080
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   437
!ComboListView methodsFor:'accessing'!
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   438
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   439
selectCondition:something
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   440
    selectCondition := something.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   441
! !
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   442
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   443
!ComboListView methodsFor:'accessing-behavior'!
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   444
501
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   445
useIndex
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   446
    "specify, if the selected components value or its index in the
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   447
     list should be sent to the model. The default is its value."
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   448
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   449
    ^ useIndex
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   450
!
0f047737ba92 supports list & model or SelectionInList
ca
parents: 368
diff changeset
   451
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   452
useIndex:aBoolean
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   453
    "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
   454
     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
   455
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   456
    useIndex := aBoolean.
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   457
684
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   458
"/    "/ change the aspectMessage - but only if it has not yet been
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   459
"/    "/ changed explicitly
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   460
"/    useIndex ifTrue:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   461
"/        changeMsg == #selection: ifTrue:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   462
"/            changeMsg := #selectionIndex:.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   463
"/            aspectMsg := #selectionIndex.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   464
"/        ]
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   465
"/    ] ifFalse:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   466
"/        changeMsg == #selectionIndex: ifTrue:[
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   467
"/            changeMsg := #selection:.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   468
"/            aspectMsg := #selection.
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   469
"/        ]
707ce2f663f0 useIndex ...
ca
parents: 682
diff changeset
   470
"/    ].
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   471
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   472
    "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
   473
    "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
   474
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   475
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   476
values:aCollection
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   477
    "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
   478
     passed via the actionBlock."
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   479
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   480
    values := aCollection.
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   481
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   482
    "Created: 27.2.1997 / 15:10:12 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   483
! !
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   484
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
!ComboListView methodsFor:'accessing-components'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
label 
181
31e8f8ab2fb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
   488
    "return the label component"
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
    ^ field
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
    "Modified: 28.2.1996 / 15:10:50 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
    "Created: 28.2.1996 / 15:13:51 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   496
!ComboListView methodsFor:'accessing-contents'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   497
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   498
contents
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   499
    "get the current value - either in the fields model
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   500
     or directly"
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   501
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   502
    |m|
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   503
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   504
    (m := field model) notNil ifTrue:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   505
        ^ m value
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   506
    ] ifFalse:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   507
        ^ field label
536
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   508
    ]
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   509
!
918612416568 accessing contents reimplemented; like contents:
ca
parents: 519
diff changeset
   510
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   511
contents:something
2876
dbeee558e9e7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2825
diff changeset
   512
    "set the current value - either in the fields model or directly"
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   513
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   514
    |m|
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   515
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   516
    (m := field model) notNil ifTrue:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   517
        m value:something
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   518
    ] ifFalse:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   519
        field label:something
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   520
    ]
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   521
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   522
    "Created: 15.7.1996 / 13:16:49 / cg"
272
6c6466cd4ea1 commentary
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   523
    "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
   524
!
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   525
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   526
selection:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   527
    "set the contents of my field; questionable"
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   528
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   529
    self contents:something
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   530
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   531
    "Created: 27.2.1997 / 15:07:37 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   532
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   533
3368
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   534
!ComboListView methodsFor:'event handling'!
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   535
3463
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   536
enableStateChanged
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   537
    |fieldBG|
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   538
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   539
    super enableStateChanged.
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   540
    self enabled ifTrue:[
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   541
        fieldBG := (styleSheet colorAt:#'comboList.backgroundColor' default:Color white).
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   542
    ] ifFalse:[
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   543
        fieldBG := View defaultViewBackgroundColor.
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   544
    ].
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   545
    field backgroundColor:fieldBG.
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   546
!
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   547
3368
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   548
keyPress:key x:x y:y
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   549
    "select by first letter"
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   550
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   551
    |idx searchKey startIndex|
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   552
3451
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   553
    list notEmptyOrNil ifTrue:[
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   554
        key == #CursorDown ifTrue:[
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   555
            self deltaSelect:1.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   556
            ^ self.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   557
        ].
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   558
        key == #CursorUp ifTrue:[
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   559
            self deltaSelect:-1.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   560
            ^ self.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   561
        ].
3368
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   562
3451
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   563
        currentIndex isNil ifTrue:[
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   564
            currentIndex := 1.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   565
        ].
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   566
        searchKey := key asLowercase.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   567
        startIndex := currentIndex + 1.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   568
        [
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   569
            idx := list findFirst:[:eachEntry| (eachEntry printString at:1 ifAbsent:Character cr) asLowercase = searchKey]
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   570
                        startingAt:startIndex.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   571
        ] doWhile:[ idx = 0 and:[startIndex ~= 1 and:[startIndex := 1. true]] ].
3368
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   572
3451
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   573
        idx = 0 ifFalse:[
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   574
            self select:idx.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   575
            ^ self.
107875ac3691 changed #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents: 3446
diff changeset
   576
        ].
3368
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   577
    ].
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   578
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   579
    ^ super keyPress:key x:x y:y
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   580
! !
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   581
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   582
!ComboListView methodsFor:'focus handling'!
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   583
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   584
showFocus:explicit
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   585
    "the button got the keyboard focus 
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   586
     (either explicit, via tabbing; or implicit, by pointer movement)
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   587
      - change any display attributes as req'd."
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   588
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   589
    (styleSheet at:#'focusHighlightStyle') == #win95 ifTrue:[
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   590
        field hasFocus:true.
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   591
        field invalidate.
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   592
    ] ifFalse:[
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   593
        ^ super showFocus:explicit
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   594
    ]
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   595
!
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   596
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   597
showNoFocus:explicit
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   598
    "the button lost the keyboard focus 
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   599
     (either explicit, via tabbing; or implicit, by pointer movement)
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   600
      - change any display attributes as req'd."
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   601
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   602
    (styleSheet at:#'focusHighlightStyle') == #win95 ifTrue:[
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   603
        field hasFocus:false.
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   604
        field invalidate.
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   605
    ] ifFalse:[
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   606
        ^ super showNoFocus:explicit
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   607
    ]
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   608
!
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   609
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   610
subviewsInFocusOrder
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   611
    "none of my subviews should get he focus"
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   612
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   613
    ^ #()
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   614
!
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   615
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   616
wantsFocusWithButtonPress
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   617
    "we want the focus, in order to do selection via mouse wheel"
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   618
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   619
    ^ true
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   620
! !
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   621
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
!ComboListView methodsFor:'initialization'!
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   624
initialize
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   625
    useIndex isNil ifTrue:[useIndex := false].
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   626
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   627
    super initialize.
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   628
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   629
    "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
   630
    "Modified: 27.2.1997 / 15:23:24 / cg"
231
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   631
!
3cb7dafa8cd2 allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
   632
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
initializeField
3368
64e841a58dd1 Show focus when tabbing to a ComboListView
Stefan Vogel <sv@exept.de>
parents: 3314
diff changeset
   634
    field := CheckLabel in:self.
519
9ab4fc771a7f better look with 2D styles
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   635
    field level:-1; borderWidth:0.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    field adjust:#left.
3314
b5a26b3e4640 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3080
diff changeset
   637
    field delegate:self.    "delegate mouseWheel events to myself"
3463
2f56e8ccb3f8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
   638
    field backgroundColor:(styleSheet colorAt:#'comboList.backgroundColor' default:Color white).
3480
5178cda62a25 changed #initialize - set font
Stefan Vogel <sv@exept.de>
parents: 3463
diff changeset
   639
    field font:font.
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
     |b|
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
     b := ComboListView new.
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
     b list:#('hello' 'world' 'this' 'is' 'st/x').
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
     b open
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    "
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
    "Created: 28.2.1996 / 15:13:46 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
    "Modified: 28.2.1996 / 15:18:40 / cg"
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
! !
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
3080
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   653
!ComboListView methodsFor:'menu interaction'!
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   654
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   655
select:anIndex
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   656
    "sent from the popped menu, when an item was selected"
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   657
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   658
    |label value chg|
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   659
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   660
    values isNil ifTrue:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   661
        value := anIndex.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   662
        useIndex ifFalse:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   663
            value := list at:anIndex.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   664
        ]
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   665
    ] ifFalse:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   666
        value := values at:anIndex
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   667
    ].
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   668
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   669
    selectCondition notNil ifTrue:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   670
        (selectCondition value:value) ifFalse:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   671
            ^ self.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   672
        ]
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   673
    ].
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   674
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   675
    label := list at:anIndex.
3314
b5a26b3e4640 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3080
diff changeset
   676
    currentIndex := anIndex.
3080
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   677
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   678
    field label:label.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   679
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   680
    "
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   681
     ST-80 style model notification ...
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   682
     this updates the model (typically, a ValueHolder)
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   683
    "
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   684
    (model notNil and:[changeMsg notNil]) ifTrue:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   685
        "/ kludge - try #value: if changeMsg is the default and
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   686
        "/ not understood by the model
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   687
        "/ this allows a valueHolder to be used, even
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   688
        "/ if the aspectMessage was not setup correctly.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   689
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   690
        chg := changeMsg.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   691
        chg == self class defaultChangeMessage ifTrue:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   692
            (model respondsTo:chg) ifFalse:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   693
                chg := #value:
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   694
            ]
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   695
        ].
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   696
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   697
        self sendChangeMessage:chg with:value
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   698
    ].
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   699
    pullDownButton turnOff.
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   700
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   701
    "
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   702
     ST/X style actionBlock evaluation ...
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   703
    "
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   704
    action notNil ifTrue:[
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   705
        action value:value
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   706
    ].
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   707
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   708
    "Created: / 27-02-1997 / 15:18:44 / cg"
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   709
    "Modified: / 28-02-1997 / 13:50:17 / cg"
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   710
    "Modified: / 15-09-2006 / 11:40:00 / User"
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   711
! !
363b2674a2f7 select condition
fm
parents: 2941
diff changeset
   712
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   713
!ComboListView methodsFor:'private'!
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   714
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   715
getValueFromModel
1206
a739c9a8a42f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   716
    |selection idx aspect newContents|
278
4a22889a5730 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 275
diff changeset
   717
307
b33b48f2a1a3 examples; protocol now compatible with PopUpList
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   718
    (model notNil and:[aspectMsg notNil]) ifTrue:[
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   719
        "/ kludge - try #value if aspect is the default and
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   720
        "/ not understood by the model
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   721
        "/ this allows a valueHolder to be used, even
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   722
        "/ 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
   723
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   724
        aspect := aspectMsg.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   725
        aspect == self class defaultAspectMessage ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   726
            (model respondsTo:aspect) ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   727
                aspect := #value
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   728
            ]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   729
        ].
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   730
1729
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   731
        aspect == #value ifTrue:[
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   732
            selection := model value
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   733
        ] ifFalse:[
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   734
            selection := model perform:aspect.
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   735
        ].
309
f2ae122f6dad allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   736
682
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   737
        selection notNil ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   738
            values notNil ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   739
                idx := values indexOf:selection
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   740
            ] ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   741
                useIndex ifTrue:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   742
                    idx := selection
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   743
                ] ifFalse:[
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   744
                    self contents:selection.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   745
                    ^ self.
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   746
                ]
861e446e3b24 checkin from browser
ca
parents: 679
diff changeset
   747
            ].
2941
51cafd3a8877 avoid error accessing a nil-list
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
   748
            list notNil ifTrue:[
51cafd3a8877 avoid error accessing a nil-list
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
   749
                newContents := list at:idx ifAbsent:nil.
51cafd3a8877 avoid error accessing a nil-list
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
   750
            ]
1206
a739c9a8a42f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   751
        ].
a739c9a8a42f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 684
diff changeset
   752
        self contents:newContents
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   753
    ].
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   754
1729
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   755
    "Created: / 15.7.1996 / 12:28:53 / cg"
d08b46a88c4e tuned #value-sending
Claus Gittinger <cg@exept.de>
parents: 1302
diff changeset
   756
    "Modified: / 1.3.2000 / 15:20:24 / cg"
215
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   757
! !
28541bca7791 get value from model
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   758
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   759
!ComboListView methodsFor:'queries'!
65229309ad5e specClass
ca
parents: 283
diff changeset
   760
65229309ad5e specClass
ca
parents: 283
diff changeset
   761
specClass
598
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   762
    "XXX no longer needed (inherited default works here)"
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   763
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   764
    self class == ComboListView ifTrue:[
1295
acc5e8e85a7b Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1291
diff changeset
   765
        ^ ComboListSpec
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   766
    ].
301
edddd206a2e5 specClass query
ca
parents: 293
diff changeset
   767
    ^ super specClass
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   768
598
288e67e06da4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   769
    "Modified: / 31.10.1997 / 19:49:34 / cg"
291
65229309ad5e specClass
ca
parents: 283
diff changeset
   770
! !
65229309ad5e specClass
ca
parents: 283
diff changeset
   771
270
35558a88d500 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   772
!ComboListView class methodsFor:'documentation'!
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
version
3480
5178cda62a25 changed #initialize - set font
Stefan Vogel <sv@exept.de>
parents: 3463
diff changeset
   775
    ^ '$Header: /cvs/stx/stx/libwidg2/ComboListView.st,v 1.47 2008-07-18 08:56:52 stefan Exp $'
131
ee1b6e7cdf75 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
! !