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