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