PopUpMenu.st
author Claus Gittinger <cg@exept.de>
Sat, 24 Apr 1999 14:02:25 +0200
changeset 1861 a582b6c0809d
parent 1859 acd3ca6d027b
child 2038 065ced8a481f
permissions -rw-r--r--
take level & borderWidth from popup.level and popup.borderWidth, setting the menuViews lvl & bw to zero (otherwise, we get confusing behavior of summing the bw's and levels)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
PopUpView subclass:#PopUpMenu
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    14
	instanceVariableNames:'menuView lastSelection memorize hideOnLeave actionLabels
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    15
		actionLines actionValues hideOnRelease defaultHideOnRelease'
1861
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
    16
	classVariableNames:''
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    17
	poolDictionaries:''
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    18
	category:'Views-Menus'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    21
!PopUpMenu class methodsFor:'documentation'!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    22
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    23
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    24
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    25
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    26
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    27
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    28
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    29
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    31
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    32
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    33
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    34
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    35
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    36
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    37
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    38
"
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    39
    This class provides PopUpMenu functionality;
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    40
    -> Actually, this class only provides the popup and shadow functionality 
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    41
       and wraps ANOTHER view, which shows the actual menu-list 
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    42
       (usually an instance of MenuView).
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    43
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    44
    PopUpMenus are usually created with a list of labels, selectors and a
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    45
    receivier. Once activated, the specified receiver will be sent a
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    46
    'selector'-message.
112
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    47
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    48
    PopupMenus may be either assigned statically to a view (via the #middleButtonMenu:
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    49
    message) or created dynamically as required.
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    50
    Static definition makes sense, if the menu stays constant and you want to
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    51
    assign it once for the lifetime of the view.
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    52
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    53
    Dynamic menus are easier to use, if the number of or look of the entries has to
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    54
    change according the internal state of some model. Also, this is the ST-80 way
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    55
    of using popupMenus. For dynamic popups, the views model is asked for a menu
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    56
    via the #menuSelector each time a button press occurs.
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    57
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
    58
    See examples section for more.
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
    59
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
    60
    [author:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
    61
        Claus Gittinger
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    62
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    63
    [see also:]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    64
        PullDownMenu MenuView
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    65
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    66
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    67
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    68
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    69
"
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    70
  The ST-80 way of opening menus is to startUp a menu,
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    71
  and use the returned value:
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    72
                                                                        [exBegin]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    73
    |p|
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    74
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    75
    p := PopUpMenu
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    76
            labels:#('foo' 'bar' 'baz').
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    77
    Transcript showCR:p startUp
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    78
                                                                        [exEnd]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    79
  It returns the index of the selected item or 0 if nothing was selected.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    80
  This opening is done by either the controller or the view (if it has
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    81
  a middleButtonMenu and/or a menuHolder).
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    82
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    83
  If the numeric index is inconvenient, alternative values may be specified
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    84
  as in (here, nil is returned if nothing was selected):
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    85
                                                                        [exBegin]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    86
    |p|
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    87
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    88
    p := PopUpMenu
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    89
            labels:#('foo' 'bar' 'baz')
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    90
            values:#('hello foo' 'hello bar' 'hello baz').
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    91
    Transcript showCR:p startUp
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    92
                                                                        [exEnd]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    93
  In ST/X, the above is actually done by a mimicri method (#startUp)
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    94
  and menus are typically created in one of the following ways:
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    95
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    96
  -> With a single actionBlock.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    97
     This is convenient, if all actions shall perform a similar task, 
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    98
     but require different arguments.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
    99
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   100
  this is evaluated, passing the selections index or value as argument.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   101
  The action block is NOT evaluated, if nothing was selected.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   102
    With index:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   103
                                                                        [exBegin]
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   104
    |p|
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   105
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   106
    p := PopUpMenu
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   107
            labels:#('foo' 'bar' 'baz').
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   108
    p action:[:item | Transcript showCR:item].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   109
    p showAtPointer
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   110
                                                                        [exEnd]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   111
    With individual arguments:
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   112
                                                                        [exBegin]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   113
    |p|
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   114
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   115
    p := PopUpMenu
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   116
            labels:#('foo' 'bar' 'baz')
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   117
            args:#('hello foo' 'hello bar' 'hello baz').
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   118
    p action:[:item | Transcript showCR:item].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   119
    p showAtPointer
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   120
                                                                        [exEnd]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   121
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   122
  -> With an explicit receiver and different selectors.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   123
     This is convenient, if you have to send per-item messages
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   124
     to some object (typically, the receiver is the view or a model)
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   125
                                                                        [exBegin]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   126
    |p m|
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   127
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   128
    m := Plug new.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   129
    m respondTo:#foo with:[Transcript showCR:'foo received'].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   130
    m respondTo:#bar with:[Transcript showCR:'bar received'].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   131
    m respondTo:#maz with:[Transcript showCR:'maz received'].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   132
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   133
    p := PopUpMenu
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   134
            labels:#('foo' 'bar' 'baz')
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   135
            selectors:#(#foo #bar #baz)
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   136
            receiver:m.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   137
    p showAtPointer
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   138
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   139
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   140
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   141
  More examples:
459
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   142
    dynamic with action instead of selector being sent:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   143
                                                                        [exBegin]
459
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   144
        |p|
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   145
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   146
        p := PopUpMenu
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   147
                labels:(($a to: $d) collect:[:char | char asString])
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   148
                selectors:nil
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   149
                receiver:nil.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   150
        p action:[:idx | Transcript showCR:'selected index is '; showCR:idx].
459
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   151
        p showAtPointer
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   152
                                                                        [exEnd]
459
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   153
5c35e2f02d27 another dynamic menu example
ca
parents: 426
diff changeset
   154
545
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   155
    individual actions:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   156
                                                                        [exBegin]
545
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   157
        |p|
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   158
        p := PopUpMenu
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   159
                labels:#('foo'
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   160
                         'bar'
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   161
                         'baz')
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   162
                selectors:#(
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   163
                            #foo
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   164
                            #bar
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   165
                            #baz).
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   166
        p actionAt:#foo put:[Transcript showCR:'foo'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   167
        p actionAt:#bar put:[Transcript showCR:'bar'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   168
        p actionAt:#baz put:[Transcript showCR:'baz'].
545
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   169
        p showAtPointer
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   170
                                                                        [exEnd]
545
18991fcbdb99 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   171
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   172
    sometimes, you want to specify both selectors and some arguments
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   173
    to be sent; this is done by:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   174
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   175
        |p|
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   176
        p := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   177
                labels:#('foo' 'bar' 'baz')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   178
                selectors:#(#foo: #bar: #foo:)
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   179
                args:#(1 2 3)
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   180
                receiver:nil.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   181
        p showAtPointer
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   182
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   183
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   184
    or, the same selector but different arguments:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   185
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   186
        |p|
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   187
        p := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   188
                labels:#('foo' 'bar' 'baz')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   189
                selectors:#foo:
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   190
                args:#(1 2 3)
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   191
                receiver:nil.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   192
        p showAtPointer
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   193
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   194
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   195
    Normally, you do not show the menu explicitely, but install
112
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   196
    it as a either as middleButtonMenu of some view or return it from
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   197
    a model. 
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   198
    (Views/Controllers button-event handler will show it when the middle
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   199
    button is pressed ...)
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   200
    Static menu:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   201
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   202
        |v m|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   203
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   204
        v := View new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   205
        m := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   206
                labels:#('lower'
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   207
                         'raise'
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   208
                         '-'
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   209
                         'destroy')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   210
                selectors:#(#lower #raise nil #destroy)
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   211
                receiver:v.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   212
        v middleButtonMenu:m.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   213
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   214
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   215
112
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   216
    Dynamic menu:
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   217
    (since we need some model which responds to a menu-message,
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   218
     we use a plug in the example below; normally, this would be your model)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   219
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   220
        |v model|
112
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   221
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   222
        model := Plug new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   223
        model respondTo:#getMenu with:[PopUpMenu labels:#('foo' 'bar')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   224
                                                 selectors:#(foo bar)].
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   225
        model respondTo:#foo with:[Transcript showCR:'models foo called'].
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   226
        model respondTo:#bar with:[Transcript showCR:'models bar called'].
112
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   227
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   228
        v := View new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   229
        v model:model; menu:#getMenu.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   230
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   231
                                                                        [exEnd]
112
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   232
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   233
    Dynamic menus are the MVC-way (i.e. ST-80) way of doing things.
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   234
    They are usually easier to use, if the menu changes depending on the models
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   235
    state. (for example, see the systemBrowsers menus being different when
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   236
    things are selected ...)
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
   237
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   238
    It is also possible, to add check-mark entries, with an entry string
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   239
    starting with the special sequence '\c' (for check-mark). The value
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   240
    passed will be the truth-state of the check-mark.
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   241
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   242
        |m v|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   243
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   244
        v := View new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   245
        m := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   246
                labels:#('\c foo'
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   247
                         '\c bar')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   248
                selectors:#(#value: #value:)
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   249
                receiver:[:v | Transcript show:'arg: '; showCR:v].
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   250
        v middleButtonMenu:m.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   251
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   252
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   253
404
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   254
    The style of the checkmark can be: check (\c), box (\b) or thumbs (\t):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   255
                                                                        [exBegin]
404
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   256
        |m v|
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   257
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   258
        v := View new.
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   259
        m := PopUpMenu
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   260
                labels:#('\c foo'
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   261
                         '\b bar'
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   262
                         '\t baz')
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   263
                selectors:#(#value: #value: #value:)
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   264
                receiver:[:v | Transcript show:'arg: '; showCR:v].
404
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   265
        v middleButtonMenu:m.
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   266
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   267
                                                                        [exEnd]
404
6a32f6111fce example added
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   268
406
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   269
    or at the end (looks better with variable fonts):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   270
                                                                        [exBegin]
406
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   271
        |m v|
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   272
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   273
        v := View new.
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   274
        m := PopUpMenu
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   275
                labels:#('foo \c'
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   276
                         'bar \b'
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   277
                         'baz \t')
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   278
                selectors:#(#value: #value: #value:)
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   279
                receiver:[:v | Transcript show:'arg: '; showCR:v].
406
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   280
        v middleButtonMenu:m.
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   281
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   282
                                                                        [exEnd]
406
00b4fb72a566 examples
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   283
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   284
    Finally, you can wrap other views into a popup menu (for example,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   285
    to implement menus with icons or other components).
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   286
    The view should respond to some messages sent from here (for
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   287
    example: #hideSubmenus, #deselectWithoutRedraw and others).
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   288
    Currently there is only one class in the system, which can be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   289
    this way (PatternMenu in the DrawTool demo):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   290
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   291
        |v p|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   292
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   293
        v := View new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   294
        p := PatternMenu new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   295
        p patterns:(Array with:Color red
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   296
                          with:Color green
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   297
                          with:Color blue).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   298
        v middleButtonMenu:(PopUpMenu forMenu:p).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   299
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   300
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   301
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   302
    or try:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   303
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   304
        |v p|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   305
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   306
        v := View new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   307
        p := PatternMenu new.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   308
        p patterns:(Array with:Color red
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   309
                          with:Color green
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   310
                          with:Color blue).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   311
        p selectors:#value:.
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   312
        p receiver:[:val | v viewBackground:val. v clear].
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   313
        p args:(Array with:Color red
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   314
                      with:Color green
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   315
                      with:Color blue).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   316
        v middleButtonMenu:(PopUpMenu forMenu:p).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   317
        v open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   318
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   319
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   320
        
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   321
    ST-80 style:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   322
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   323
    The above menus all did some message send on selection; it is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   324
    also possible, to use Smalltalk-80 style menus (which return some value
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   325
    from their startup method):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   326
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   327
        |m selection|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   328
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   329
        m := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   330
                labels:#('one' 'two' 'three').
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   331
        selection := m startUp.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   332
        Transcript show:'the selection was: '; showCR:selection
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   333
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   334
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   335
    startUp will return the entries index, or 0 if there was no selection.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   336
    You can also specify an array of values to be returned instead of the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   337
    index:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   338
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   339
        |m selection|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   340
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   341
        m := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   342
                labels:#('one' 'two' 'three')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   343
                values:#(10 20 30).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   344
        selection := m startUp.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   345
        Transcript show:'the value was: '; showCR:selection
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   346
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   347
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   348
    In ST/X style menus, separating lines between entries are created
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   349
    by a '-'-string as its label text (and corresponding nil-entries in the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   350
    selectors- and args-arrays).
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   351
    In ST-80, you have to pass the indices of the lines in an extra array:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   352
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   353
        |m selection|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   354
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   355
        m := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   356
                labels:#('one' 'two' 'three' 'four' 'five')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   357
                lines:#(2 4).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   358
        selection := m startUp.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   359
        Transcript show:'the value was: '; showCR:selection
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   360
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   361
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   362
    or:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   363
                                                                        [exBegin]
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   364
        |m selection|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   365
284
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   366
        m := PopUpMenu
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   367
                labels:#('one' 'two' 'three')
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   368
                lines:#(2)
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   369
                values:#(10 20 30).
fb625951b7fc beispiel
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
   370
        selection := m startUp.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   371
        Transcript show:'the value was: '; showCR:selection
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   372
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   373
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   374
    Use whichever interface you prefer.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   375
"
119
claus
parents: 112
diff changeset
   376
! !
claus
parents: 112
diff changeset
   377
claus
parents: 112
diff changeset
   378
!PopUpMenu class methodsFor:'instance creation'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   379
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   380
forMenu:aMenuView
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   381
    "this wraps an already existing menu - allowing to put any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   382
     view (not just MenuViews) into popups (for example, menus
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   383
     with icons, or other components).
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   384
     Currently, there is only one example of different menus in
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   385
     the system (PatternMenu in the DrawTool) which could be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   386
     this way.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   387
     The view should respond to some of the menuView messages
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   388
     (such as hideSubmenu, deselectWithoutRedraw etc.)"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   389
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   390
    |newMenu|
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   391
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   392
    newMenu := self onSameDeviceAs:aMenuView. 
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   393
    newMenu addSubView:aMenuView.
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   394
    newMenu menuView:aMenuView.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   395
    ^ newMenu
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   396
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   397
    "Modified: 25.2.1997 / 20:52:42 / cg"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   398
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   399
1505
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   400
itemList:itemList resources:resources
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   401
    "like labels:selectors:... messages, but expects a single collection,
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   402
     containing items row-wise (i.e. elements are themself arrays, consisting of
1606
8ab3d7e85ea2 comment
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   403
        label [selector [accelerator [arg]]]
1505
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   404
     if resources are non-nil, labels are translated using the translations found there.
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   405
    "
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   406
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   407
    ^ self
1506
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   408
        itemList:itemList resources:resources receiver:nil for:nil
1505
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   409
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   410
    "the sometimes more convenient:
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   411
        |p|
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   412
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   413
        p := PopUpMenu
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   414
                itemList:#(('foo' doFoo CtrlF)
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   415
                           ('-')
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   416
                           ('bar' doBar CtrlB)
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   417
                           ('baz' doBaz CtrlZ))
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   418
                resources:nil.
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   419
        p showAtPointer
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   420
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   421
     does the same as:
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   422
        |p|
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   423
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   424
        p := PopUpMenu
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   425
                labels:#('foo' '-' 'bar' 'baz')
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   426
                selectors:#(doFoo nil doBar doBaz)
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   427
                accelerators:#(CtrlF nil CtrlB CtrlZ).
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   428
        p showAtPointer
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   429
    "
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   430
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   431
!
66e010d679a9 added #itemList: instance creation.
Claus Gittinger <cg@exept.de>
parents: 1442
diff changeset
   432
1543
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   433
itemList:itemList resources:resources performer:menuPerformer
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   434
    "like labels:selectors:... messages, but expects a single collection,
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   435
     containing items row-wise (i.e. elements are themself arrays, consisting of
1606
8ab3d7e85ea2 comment
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
   436
        label [selector [accelerator [arg]]]
1543
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   437
     if resources are non-nil, labels are translated using the translations found there.
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   438
    "
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   439
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   440
    ^ self
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   441
        itemList:itemList resources:resources receiver:menuPerformer for:nil
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   442
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   443
    "Created: / 21.5.1998 / 15:31:42 / cg"
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   444
!
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   445
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   446
itemList:itemList resources:resources performer:menuPerformer for:aView
1506
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   447
    "like labels:selectors:... messages, but expects a single collection,
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   448
     containing items row-wise (i.e. elements are themself arrays, consisting of
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   449
        label [selector [accelerator [arg]]]
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   450
     if resources are non-nil, labels are translated using the translations found there.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   451
    "
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   452
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   453
    |n labels selectors accelerators args anyArg|
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   454
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   455
    n := itemList size.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   456
    labels := Array new:n.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   457
    selectors := Array new:n.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   458
    accelerators := Array new:n.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   459
    anyArg := false.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   460
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   461
    itemList keysAndValuesDo:[:idx :item |
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   462
        |label selector accelerator arg|
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   463
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   464
        label := item at:1.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   465
        labels at:idx put:label.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   466
        item size > 1 ifTrue:[
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   467
            selector := item at:2.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   468
            selectors at:idx put:selector.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   469
            item size > 2 ifTrue:[
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   470
                accelerator := item at:3.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   471
                accelerators at:idx put:accelerator.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   472
                item size > 3 ifTrue:[
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   473
                    arg := item at:4.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   474
                    anyArg ifFalse:[
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   475
                        anyArg := true.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   476
                        args := Array new:n.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   477
                    ].
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   478
                    args at:idx put:arg.    
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   479
                ]
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   480
            ]
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   481
        ].
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   482
    ].
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   483
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   484
    resources notNil ifTrue:[
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   485
        labels := resources array:labels
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   486
    ].
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   487
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   488
    ^ self
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   489
        labels:labels
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   490
        selectors:selectors
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   491
        accelerators:accelerators
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   492
        args:args 
1543
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   493
        receiver:menuPerformer 
1506
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   494
        for:aView
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   495
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   496
    "this is sometimes more convenient:
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   497
        |p|
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   498
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   499
        p := PopUpMenu
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   500
                itemList:#(('foo' doFoo CtrlF)
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   501
                           ('-')
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   502
                           ('bar' doBar CtrlB)
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   503
                           ('baz' doBaz CtrlZ))
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   504
                resources:nil.
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   505
        p showAtPointer
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   506
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   507
     and does the same as:
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   508
        |p|
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   509
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   510
        p := PopUpMenu
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   511
                labels:#('foo' '-' 'bar' 'baz')
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   512
                selectors:#(doFoo nil doBar doBaz)
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   513
                accelerators:#(CtrlF nil CtrlB CtrlZ).
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   514
        p showAtPointer
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   515
    "
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   516
1543
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   517
    "Created: / 21.5.1998 / 15:32:39 / cg"
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   518
!
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   519
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   520
itemList:itemList resources:resources receiver:menuPerformer for:aView
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   521
    "like labels:selectors:... messages, but expects a single collection,
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   522
     containing items row-wise (i.e. elements are themself arrays, consisting of
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   523
        label [selector [accelerator [arg]]]
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   524
     if resources are non-nil, labels are translated using the translations found there.
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   525
    "
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   526
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   527
    ^ self
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   528
        itemList:itemList resources:resources performer:menuPerformer for:aView
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   529
74f627922fea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   530
    "Modified: / 21.5.1998 / 15:33:04 / cg"
1506
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   531
!
63fb353fe997 better #itemList entry
Claus Gittinger <cg@exept.de>
parents: 1505
diff changeset
   532
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   533
labels:labels args:args 
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   534
    "create and return a menu with label-items and args. 
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   535
     The actionBlock has to be defined later"
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   536
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   537
    ^ self labels:labels selectors:nil accelerators:nil args:args receiver:nil for:nil
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   538
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   539
    "
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   540
     |m|
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   541
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   542
     m := PopUpMenu labels:#('foo' 'bar')
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   543
                      args:#('hello world' 'how about this').
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   544
     m action:[:arg |
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   545
        Transcript showCR:arg
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   546
     ].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   547
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   548
     m showAtPointer
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   549
    "
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   550
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   551
    "Modified: 25.5.1996 / 17:01:43 / cg"
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   552
!
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   553
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   554
labels:labels selector:aSelector args:args receiver:anObject
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   555
    "create and return a popup menu with labels as entries.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   556
     Each item will send aSelector with a corresponding argument from the
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   557
     args array to anObject. The menu is created on the default DIsplay"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   558
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   559
    "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   560
     OBSOLETE protocol: #labels:selectors:... knows how to handle single-symbol selectors-arg
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   561
    "
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   562
    ^ self labels:labels selectors:aSelector accelerators:nil args:args receiver:anObject
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   563
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   564
    "Modified: 28.2.1996 / 19:01:12 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   565
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   566
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   567
labels:labels selector:aSelector args:args receiver:anObject for:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   568
    "create and return a popup menu with labels as entries.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   569
     Each item will send aSelector with a corresponding argument from the
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   570
     args array to anObject. The menu is created on the same physical device
258
ae4b8f1a6738 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   571
     as aView (which is only of interest in multi-Display applications; 
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   572
     typical applications can use the sibbling message without the for: argument)."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   573
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   574
    "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   575
     OBSOLETE protocol: #labels:selectors:... knows how to handle single-symbol selectors-arg
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   576
    "
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   577
    ^ self labels:labels selectors:aSelector accelerators:nil args:args receiver:anObject for:aView
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   578
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   579
    "Modified: 28.2.1996 / 19:01:29 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   580
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   581
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   582
labels:labels selectors:selectors 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   583
    "create and return a menu with label-items and selectors. The receiver
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   584
     will either be defined later, or not used at all (if opened via startUp)"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   585
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   586
    ^ self labels:labels selectors:selectors accelerators:nil args:nil receiver:nil for:nil
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   587
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   588
    "Modified: 28.2.1996 / 19:01:35 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   589
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   590
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   591
labels:labels selectors:selectors accelerators:shorties 
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   592
    "create and return a menu with label-items and selectors. The receiver
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   593
     will either be defined later, or not used at all (if opened via startUp)"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   594
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   595
    ^ self labels:labels selectors:selectors accelerators:shorties args:nil receiver:nil for:nil
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   596
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   597
    "Created: 28.2.1996 / 18:58:52 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   598
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   599
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   600
labels:labels selectors:selectors accelerators:shorties args:args receiver:anObject
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   601
    "create and return a popup menu with labels as entries.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   602
     Each item will send a corresponding selector:argument from the selectors-
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   603
     and args array to anObject. The menu is created on the default Display"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   604
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   605
    ^ self labels:labels selectors:selectors accelerators:shorties args:args receiver:anObject for:nil
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   606
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   607
    "Created: 28.2.1996 / 18:59:03 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   608
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   609
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   610
labels:labels selectors:selectors accelerators:shorties args:args receiver:anObject for:aView
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   611
    "create and return a popup menu with labels as entries.
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   612
     Each item will send a corresponding selector:argument from the selectors-
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   613
     and args array to anObject. The menu is created on the same physical device
258
ae4b8f1a6738 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   614
     as aView (which is only of interest in multi-Display applications; 
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   615
     typical applications can use the sibbling message without the for: argument)."
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   616
1861
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   617
    |newMenu m|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   618
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   619
    newMenu := self onSameDeviceAs:aView. 
1861
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   620
    m := (MenuView
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   621
            labels:labels
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   622
            selectors:selectors
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   623
            accelerators:shorties 
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   624
            args:args
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   625
            receiver:anObject
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   626
            in:newMenu).
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   627
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   628
    m level:0; borderWidth:0.
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
   629
    newMenu menuView:m.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   630
    ^ newMenu
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   631
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   632
    "Created: 28.2.1996 / 18:59:25 / cg"
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   633
    "Modified: 25.2.1997 / 20:52:47 / cg"
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   634
!
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   635
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   636
labels:labels selectors:selectors accelerators:shorties receiver:anObject
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   637
    "create and return a popup menu with labels as entries.
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   638
     Each item will send a message with a selector from the corresponding 
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   639
     selectors-array.
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   640
     The menu is created on the default Display."
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   641
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   642
    ^ self labels:labels selectors:selectors accelerators:shorties args:nil receiver:anObject for:nil
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   643
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   644
    "Created: 28.2.1996 / 19:00:49 / cg"
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   645
!
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   646
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   647
labels:labels selectors:selectors args:argArray 
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   648
    "create and return a menu with label-items and selectors. The receiver
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   649
     will either be defined later, or not used at all (if opened via startUp)"
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   650
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   651
    ^ self labels:labels selectors:selectors accelerators:nil args:argArray receiver:nil for:nil
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   652
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   653
    "Modified: 28.2.1996 / 19:01:45 / cg"
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   654
!
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   655
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   656
labels:labels selectors:selectors args:args receiver:anObject
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   657
    "create and return a popup menu with labels as entries.
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   658
     Each item will send a corresponding selector:argument from the selectors-
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   659
     and args array to anObject. The menu is created on the default Display"
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   660
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   661
    ^ self labels:labels selectors:selectors accelerators:nil args:args receiver:anObject for:nil
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   662
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   663
    "Modified: 28.2.1996 / 19:01:49 / cg"
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   664
!
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   665
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   666
labels:labels selectors:selectors args:args receiver:anObject for:aView
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   667
    "create and return a popup menu with labels as entries.
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   668
     Each item will send a corresponding selector:argument from the selectors-
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   669
     and args array to anObject. The menu is created on the same physical device
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   670
     as aView (which is only of interest in multi-Display applications; 
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   671
     typical applications can use the sibbling message without the for: argument)."
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   672
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   673
    ^ self labels:labels selectors:selectors accelerators:nil args:args receiver:anObject for:aView
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   674
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   675
    "Modified: 28.2.1996 / 19:03:58 / cg"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   676
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   677
119
claus
parents: 112
diff changeset
   678
labels:labels selectors:selectors receiver:anObject
claus
parents: 112
diff changeset
   679
    "create and return a popup menu with labels as entries.
claus
parents: 112
diff changeset
   680
     Each item will send a message with a selector from the corresponding 
claus
parents: 112
diff changeset
   681
     selectors-array.
claus
parents: 112
diff changeset
   682
     The menu is created on the default Display."
claus
parents: 112
diff changeset
   683
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   684
    ^ self labels:labels selectors:selectors accelerators:nil args:nil receiver:anObject for:nil
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   685
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   686
    "Modified: 28.2.1996 / 19:02:07 / cg"
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   687
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   688
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   689
labels:labels selectors:selectors receiver:anObject for:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   690
    "create and return a popup menu with labels as entries.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   691
     Each item will send a corresponding selector from the selectors-array
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   692
     to anObject. The menu is created on the same physical device
258
ae4b8f1a6738 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
   693
     as aView (which is only of interest in multi-Display applications; 
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   694
     typical applications can use the sibbling message without the for: argument)."
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   695
426
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   696
    ^ self labels:labels selectors:selectors accelerators:nil args:nil receiver:anObject for:aView
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   697
bf35bf40ab11 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 425
diff changeset
   698
    "Modified: 28.2.1996 / 19:02:10 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   699
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   700
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   701
!PopUpMenu class methodsFor:'ST-80 instance creation'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   702
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   703
labelArray:labels lines:lines values:values 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   704
    "ST80R4 compatibility"
119
claus
parents: 112
diff changeset
   705
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   706
    ^ self labels:labels lines:lines values:values 
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   707
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   708
119
claus
parents: 112
diff changeset
   709
labelArray:labels values:values 
claus
parents: 112
diff changeset
   710
    "ST80R4 compatibility"
claus
parents: 112
diff changeset
   711
claus
parents: 112
diff changeset
   712
    ^ self labels:labels lines:nil values:values 
claus
parents: 112
diff changeset
   713
!
claus
parents: 112
diff changeset
   714
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   715
labelList:labels 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   716
    "ST80R4 compatibility:
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   717
	given a list consisting of group label entries (to be separated by
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   718
	lines), convert into standard form (using '-' for lines.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   719
    "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   720
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   721
    ^ self labelList:labels values:nil
119
claus
parents: 112
diff changeset
   722
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   723
    "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   724
     (PopUpMenu labels:#('1' '2' '3')) showAtPointer
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   725
     (PopUpMenu labelList:#(('1') ('2' '3'))) showAtPointer    
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   726
     (PopUpMenu labelList:#(('1') ('2') ('3'))) showAtPointer    
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   727
    "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   728
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   729
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   730
labelList:labels lines:lines values:values 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   731
    "mhmh what is that ?"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   732
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   733
    ^ (self new) labels:labels lines:lines values:values 
119
claus
parents: 112
diff changeset
   734
!
claus
parents: 112
diff changeset
   735
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   736
labelList:labels values:values 
119
claus
parents: 112
diff changeset
   737
    "ST80R4 compatibility:
claus
parents: 112
diff changeset
   738
	given a list consisting of group label entries (to be separated by
claus
parents: 112
diff changeset
   739
	lines), convert into standard form (using '-' for lines.
claus
parents: 112
diff changeset
   740
    "
claus
parents: 112
diff changeset
   741
claus
parents: 112
diff changeset
   742
    |newLabels newValues lS vS first|
claus
parents: 112
diff changeset
   743
claus
parents: 112
diff changeset
   744
    newLabels := OrderedCollection new.
claus
parents: 112
diff changeset
   745
    newValues := OrderedCollection new.
claus
parents: 112
diff changeset
   746
    lS := ReadStream on:labels.
claus
parents: 112
diff changeset
   747
    values notNil ifTrue:[vS := ReadStream on:values].
claus
parents: 112
diff changeset
   748
    first := true.
claus
parents: 112
diff changeset
   749
    [lS atEnd] whileFalse:[
claus
parents: 112
diff changeset
   750
	|entry|
claus
parents: 112
diff changeset
   751
claus
parents: 112
diff changeset
   752
	entry := lS next.
claus
parents: 112
diff changeset
   753
	entry isCollection ifTrue:[
claus
parents: 112
diff changeset
   754
	    first ifFalse:[
claus
parents: 112
diff changeset
   755
		newLabels add:'-'.
claus
parents: 112
diff changeset
   756
		values notNil ifTrue:[newValues add:nil]
claus
parents: 112
diff changeset
   757
	    ].
claus
parents: 112
diff changeset
   758
	    newLabels addAll:entry.
claus
parents: 112
diff changeset
   759
	    values notNil ifTrue:[newValues addAll:(vS next:entry size)]
claus
parents: 112
diff changeset
   760
	] ifFalse:[
claus
parents: 112
diff changeset
   761
	    newLabels add:entry.
claus
parents: 112
diff changeset
   762
	    values notNil ifTrue:[newValues add:(vS next)]
claus
parents: 112
diff changeset
   763
	].
claus
parents: 112
diff changeset
   764
	first := false.
claus
parents: 112
diff changeset
   765
    ].
claus
parents: 112
diff changeset
   766
    values isNil ifTrue:[
claus
parents: 112
diff changeset
   767
	^ self labels:newLabels
claus
parents: 112
diff changeset
   768
    ].
claus
parents: 112
diff changeset
   769
    ^ self labels:newLabels values:newValues
claus
parents: 112
diff changeset
   770
claus
parents: 112
diff changeset
   771
    "
claus
parents: 112
diff changeset
   772
     (PopUpMenu labels:#('1' '2' '3') values:#(1 2 3)) showAtPointer
claus
parents: 112
diff changeset
   773
     (PopUpMenu labelList:#(('1') ('2' '3')) values:#(1 2 3)) showAtPointer    
claus
parents: 112
diff changeset
   774
     (PopUpMenu labelList:#(('1') ('2') ('3')) values:#(1 2 3)) showAtPointer    
claus
parents: 112
diff changeset
   775
    "
claus
parents: 112
diff changeset
   776
!
claus
parents: 112
diff changeset
   777
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   778
labels:labels 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   779
    "ST80R2 compatibility"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   780
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   781
    ^ self labels:labels lines:nil values:nil 
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   782
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   783
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   784
labels:labels lines:lines 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   785
    "ST80R2 compatibility"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   786
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   787
    ^ self labels:labels lines:lines values:nil
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   788
!
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   789
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   790
labels:labels lines:lines values:values 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   791
    "ST80R2 compatibility"
127
claus
parents: 126
diff changeset
   792
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   793
    ^ (self new) labels:labels lines:lines values:values 
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   794
!
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   795
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   796
labels:labels values:values 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   797
    "ST80R2 compatibility"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   798
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   799
    ^ self labels:labels lines:nil values:values 
127
claus
parents: 126
diff changeset
   800
! !
claus
parents: 126
diff changeset
   801
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   802
!PopUpMenu methodsFor:'ST-80 activation'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   803
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   804
startUp
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   805
    "start the menu modal - return the selected value,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   806
     or - if no values where specified - return the index.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   807
     If nothing was selected, return 0.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   808
     Modal - i.e. stay in the menu until finished.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   809
     This is the ST-80 way of launching a menu."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   810
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   811
    ^ self startUpAt:nil
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   812
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   813
    "
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   814
     Transcript showCR:(PopUpMenu labels:#('foo' 'bar' 'baz')) startUp 
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   815
     Transcript showCR:(PopUpMenu labels:#('foo' 'bar' 'baz')
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   816
                                  values:#(foo bar baz)) startUp
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   817
    "
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   818
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   819
    "Modified: 10.1.1996 / 20:16:40 / cg"
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   820
!
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   821
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   822
startUpAt:aPoint
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   823
    "start the menu modal - return the selected value,
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   824
     or - if no values where specified - return the index.
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   825
     If nothing was selected, return 0.
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   826
     Modal - i.e. stay in the menu until finished.
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   827
     This is the ST-80 way of launching a menu."
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   828
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1285
diff changeset
   829
    |return rec sel0 sel1 arg myAction|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   830
119
claus
parents: 112
diff changeset
   831
    return := 0.
1175
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
   832
"/    menuView args notNil ifTrue:[
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
   833
"/        return := nil
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
   834
"/    ].
119
claus
parents: 112
diff changeset
   835
495
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   836
    "/
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   837
    "/ arrange for the menu to evaluate this action,
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   838
    "/ instead of directly sending any messages to the menuReceiver.
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   839
    "/ (which used to be the ST/X way, menus worked).
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   840
    "/ This works better with menuPerformers - which were not
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   841
    "/ supported when ST/X menus were originally written.
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   842
    "/ The old ST/X mechanism may vanish.
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   843
    "/
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   844
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   845
    menuView action isNil ifTrue:[
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1285
diff changeset
   846
        myAction := true.
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   847
        menuView action:[:menuView :selected |
726
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   848
            |actionIndex value sel retVal selIdx
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   849
             args selectors checkFlags check|
119
claus
parents: 112
diff changeset
   850
878
b1b2839ff515 if the menu has an item-action, do not perform
ca
parents: 754
diff changeset
   851
            selected isNil ifTrue:[
b1b2839ff515 if the menu has an item-action, do not perform
ca
parents: 754
diff changeset
   852
                "/ the menu has already sent a message or performed an item-action; do nothing here
1175
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
   853
                ^ 0
878
b1b2839ff515 if the menu has an item-action, do not perform
ca
parents: 754
diff changeset
   854
            ].
b1b2839ff515 if the menu has an item-action, do not perform
ca
parents: 754
diff changeset
   855
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   856
            retVal := 0.
495
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   857
726
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   858
            selIdx := menuView selection.
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   859
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   860
            args := menuView args.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   861
            selectors := menuView selectors.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   862
            checkFlags := menuView checkFlags.
495
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   863
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   864
            args isNil ifTrue:[
495
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   865
                selectors notNil ifTrue:[
726
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   866
                    sel0 := selectors at:selIdx.
568
ba7d2bc390ae oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents: 545
diff changeset
   867
                ].
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   868
            ] ifFalse:[
726
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   869
                actionIndex := selected.
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   870
                actionIndex notNil ifTrue:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   871
                    actionValues isNil ifTrue:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   872
                        selectors notNil ifTrue:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   873
                            "/ mhmh an ST/X menu started the ST-80 way
568
ba7d2bc390ae oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents: 545
diff changeset
   874
726
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   875
                            sel1 := selectors at:selIdx.
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   876
                            arg := actionIndex.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   877
                        ] ifFalse:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   878
                            retVal := actionIndex
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   879
                        ]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   880
                    ] ifFalse:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   881
                        retVal := actionValues at:actionIndex.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   882
                        (retVal isKindOf:PopUpMenu) ifTrue:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   883
                            retVal := retVal startUp
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   884
                        ]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   885
                    ]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   886
                ] ifFalse:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   887
                    "/ mhmh an ST/X menu started the ST-80 way
568
ba7d2bc390ae oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents: 545
diff changeset
   888
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   889
                    selectors notNil ifTrue:[
726
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   890
                        sel0 := selectors at:selIdx.
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   891
                    ].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   892
                ]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   893
            ].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   894
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   895
            checkFlags notNil ifTrue:[
726
bef52bf8f6c3 oops - menuAction is now called with arg if there is one
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   896
                check := checkFlags at:selIdx.
692
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   897
                check notNil ifTrue:[
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   898
                    arg := check.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   899
                    sel1 := sel0.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   900
                    sel0 := nil.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   901
                ]
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   902
            ].
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   903
            return := retVal.
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   904
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   905
            menuView action:nil
65c5499f4cea examples
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
   906
        ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   907
    ].
495
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   908
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   909
    aPoint isNil ifTrue:[
1539
fb1366367049 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1506
diff changeset
   910
        self showAt:(device pointerPosition) resizing:true
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   911
    ] ifFalse:[
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   912
        self showAt:aPoint.
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   913
    ].
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1285
diff changeset
   914
    myAction == true ifTrue:[menuView action:nil].
96
5996b2afa4fb *** empty log message ***
claus
parents: 95
diff changeset
   915
5996b2afa4fb *** empty log message ***
claus
parents: 95
diff changeset
   916
    "/ 
5996b2afa4fb *** empty log message ***
claus
parents: 95
diff changeset
   917
    "/ mhmh an ST/X menu started the ST-80 way
5996b2afa4fb *** empty log message ***
claus
parents: 95
diff changeset
   918
    "/
5996b2afa4fb *** empty log message ***
claus
parents: 95
diff changeset
   919
    (sel0 notNil or:[sel1 notNil]) ifTrue:[
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   920
        rec := menuView receiver.
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   921
        sel0 notNil ifTrue:[
495
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   922
            ^ sel0
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   923
        ].
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
   924
        ^ Array with:sel1 with:arg.
95
7535cfca9509 *** empty log message ***
claus
parents: 81
diff changeset
   925
    ].
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
   926
    ^ return
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   927
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   928
    "
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   929
     Transcript showCR:(PopUpMenu labels:#('foo' 'bar' 'baz')) startUp 
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   930
     Transcript showCR:(PopUpMenu labels:#('foo' 'bar' 'baz')
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   931
                                  values:#(foo bar baz)) startUp
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   932
    "
281
0f41c95fa722 added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   933
1539
fb1366367049 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1506
diff changeset
   934
    "Created: / 10.1.1996 / 20:11:42 / cg"
fb1366367049 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1506
diff changeset
   935
    "Modified: / 20.5.1998 / 22:39:03 / cg"
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   936
!
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   937
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   938
startUpWithHeading:aString
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   939
    "start the menu modal - return the selected value,
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   940
     or - if no values where specified - return the index.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   941
     If nothing was selected, return 0.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   942
     Modal - i.e. stay in the menu until finished.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   943
     This is the ST-80 way of launching a menu."
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   944
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   945
    defaultHideOnRelease := false.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   946
    menuView labels notNil ifTrue:[
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   947
	menuView labels:(Array with:aString with:'=') , menuView labels.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   948
    ].
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   949
    menuView selectors notNil ifTrue:[
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   950
	menuView selectors:(Array with:nil with:nil) , menuView selectors.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   951
    ].
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   952
"/    menuView disable:1; disable:2.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   953
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   954
    ^ self startUp.
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   955
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   956
    "
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   957
     (PopUpMenu
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   958
	labels:#('foo' 'bar'))
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   959
	startUp
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   960
    "
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   961
    "
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   962
     (PopUpMenu
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   963
	labels:#('foo' 'bar'))
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   964
	startUpWithHeading:'hello'
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
   965
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   966
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   967
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   968
!PopUpMenu methodsFor:'accessing-behavior'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   969
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   970
hideOnLeave:aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   971
    "set/clear the hideOnLeave attribute, which controls
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   972
     if the menu should be hidden when the pointer leaves
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   973
     the view (used with multiple-menus)"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   974
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   975
    hideOnLeave := aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   976
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   977
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   978
hideOnRelease:aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   979
    "set/clear the hideOnRelease attribute, which controls
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   980
     if the menu should be hidden when the button is released"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   981
335
81c8965c4437 hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   982
    defaultHideOnRelease := aBoolean.
81c8965c4437 hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   983
    menuView hideOnRelease:aBoolean
81c8965c4437 hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   984
81c8965c4437 hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   985
    "Modified: 9.2.1996 / 02:06:15 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   986
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   987
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   988
!PopUpMenu methodsFor:'accessing-items'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   989
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   990
indexOf:indexOrName
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   991
    "return the index of a submenu - or 0 if there is none"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   992
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   993
    ^ menuView indexOf:indexOrName
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   994
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   995
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   996
labels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   997
    "return the list of labels"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   998
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   999
    actionLabels notNil ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1000
	^ actionLabels asStringCollection
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1001
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1002
    ^ menuView list
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1003
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1004
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1005
labels:labelString lines:lineArray values:valueArray
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1006
    "define the menu the ST-80 way (with labels and lines defined separately)"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1007
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1008
    |labelArray argArray convertedLabels 
1175
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1009
     offs dstOffs linePos m|
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1010
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1011
    actionLabels := labelString.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1012
    actionLines := lineArray.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1013
    actionValues := valueArray.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1014
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1015
    labelArray := labelString asStringCollection.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1016
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1017
    convertedLabels := Array new:(labelArray size + lineArray size).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1018
    argArray := Array new:(labelArray size + lineArray size).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1019
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1020
    offs := 1.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1021
    dstOffs := 1.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1022
    1 to:lineArray size do:[:lineIndex |
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1023
        linePos := lineArray at:lineIndex.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1024
        [offs <= linePos] whileTrue:[
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1025
            convertedLabels at:dstOffs put:(labelArray at:offs).
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1026
            argArray at:dstOffs put:offs.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1027
            offs := offs + 1.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1028
            dstOffs := dstOffs + 1
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1029
        ].
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1030
        convertedLabels at:dstOffs put:'-'.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1031
        argArray at:dstOffs put:nil.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1032
        dstOffs := dstOffs + 1
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1033
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1034
    [offs <= labelArray size] whileTrue:[
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1035
        convertedLabels at:dstOffs put:(labelArray at:offs).
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1036
        argArray at:dstOffs put:offs.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1037
        offs := offs + 1.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1038
        dstOffs := dstOffs + 1
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1039
    ].
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1040
1175
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1041
    m := MenuView
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1042
            labels:convertedLabels
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1043
            selectors:nil
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1044
            args:argArray
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1045
            receiver:nil 
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1046
            in:self.
1861
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1047
    m level:0; borderWidth:0.
1175
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1048
    self menuView:m
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1049
9c8aec66cc17 startUp must return 0 if nothing was selected
Claus Gittinger <cg@exept.de>
parents: 1150
diff changeset
  1050
    "Modified: 2.4.1997 / 15:57:52 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1051
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1052
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1053
lines
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1054
    "st-80 compatibility"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1055
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1056
    ^ actionLines
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1057
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1058
518
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1059
menuAt:indexOrName
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1060
    "return the submenu for entry indexOrName."
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1061
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1062
    ^ self subMenuAt:indexOrName
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1063
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1064
    "Created: 24.3.1996 / 17:11:05 / cg"
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1065
!
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1066
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1067
numberOfItems
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1068
    "return the number of items in the menu"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1069
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1070
    actionLabels notNil ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1071
	^ actionLabels asStringCollection size
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1072
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1073
    ^ menuView list size
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1074
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1075
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1076
remove:indexOrName
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1077
    "remove a menu entry"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1078
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1079
    menuView remove:indexOrName
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1080
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1081
518
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1082
subMenuAt:indexOrName
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1083
    "return the submenu for entry indexOrName"
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1084
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1085
    ^ menuView subMenuAt:indexOrName
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1086
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1087
    "Created: 24.3.1996 / 17:09:15 / cg"
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1088
!
731c905a6d89 unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
  1089
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1090
subMenuAt:indexOrName put:aMenu
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1091
    "define a submenu to be shown for entry indexOrName"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1092
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1093
"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1094
    aMenu hideOnLeave:true.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1095
"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1096
    menuView subMenuAt:indexOrName put:aMenu.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1097
    "tell the submenu to notify me when action is performed"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1098
    aMenu superMenu:self.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1099
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1100
    "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1101
     |v m someObject|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1102
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1103
     v := View new.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1104
     m := PopUpMenu labels:#('1' '2' '3')
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1105
		 selectors:#(one two nil)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1106
		  receiver:someObject 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1107
		       for:nil.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1108
     m subMenuAt:3 put:(PopUpMenu
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1109
			     labels:#('a' 'b' 'c')
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1110
			  selectors:#(a b c)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1111
			   receiver:someObject 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1112
				for:nil).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1113
     v middleButtonMenu:m.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1114
     v realize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1115
    "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1116
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1117
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1118
values
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1119
    "st-80 compatibility"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1120
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1121
    ^ actionValues
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1122
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1123
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1124
values:aValueArray
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1125
    "st-80 compatibility"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1126
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1127
    actionValues := aValueArray
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1128
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1129
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1130
!PopUpMenu methodsFor:'accessing-look'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1131
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1132
font:aFont
665
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1133
    "set the menus font.
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1134
     CAVEAT: with the addition of Text objects,
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1135
             this method is going to be obsoleted by a textStyle
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1136
             method, which allows specific control over
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1137
             normalFont/boldFont/italicFont parameters."
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1138
1233
c9cd0547db29 delegate font: update labels
ca
parents: 1175
diff changeset
  1139
    preferredExtent := nil.
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1140
    menuView font:aFont
665
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1141
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1142
    "Modified: 22.5.1996 / 12:36:53 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1143
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1144
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1145
viewBackground:aColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1146
    "this is a kludge and will vanish ..."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1147
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1148
    super viewBackground:aColor.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1149
    menuView viewBackground:aColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1150
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1151
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1152
!PopUpMenu methodsFor:'accessing-mvc'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1153
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1154
changeMessage
754
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1155
    "set the changeMessage from my menu"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1156
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1157
    ^ menuView changeMessage
754
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1158
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1159
    "Modified: 5.6.1996 / 17:08:52 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1160
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1161
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1162
changeMessage:aSymbol
754
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1163
    "set the changeMessage - forward to my menu"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1164
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1165
    menuView changeMessage:aSymbol
754
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1166
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1167
    "Modified: 5.6.1996 / 17:08:41 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1168
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1169
962
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1170
menuPerformer
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1171
    "get the menuPerformer - forwarded to my menuViews"
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1172
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1173
    ^ menuView menuPerformer
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1174
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1175
    "Modified: 5.6.1996 / 17:08:30 / cg"
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1176
    "Created: 21.1.1997 / 15:40:22 / cg"
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1177
!
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1178
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1179
menuPerformer:someone
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1180
    "set the menuPerformer - forwarded to my menuViews"
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1181
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1182
    menuView menuPerformer:someone
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1183
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1184
    "Modified: 5.6.1996 / 17:08:30 / cg"
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1185
    "Created: 21.1.1997 / 15:40:14 / cg"
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1186
!
1f1033090efe menuPerformer messages down
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
  1187
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1188
model 
753
40b85851bffb comment
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1189
    "return my menuViews model"
40b85851bffb comment
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1190
40b85851bffb comment
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1191
    ^ menuView model
40b85851bffb comment
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1192
40b85851bffb comment
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1193
    "Modified: 5.6.1996 / 14:16:53 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1194
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1195
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1196
model:aModel
754
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1197
    "set the model - forwarded to my menuViews"
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1198
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1199
    menuView model:aModel
754
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1200
4db5b854cc88 comment
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1201
    "Modified: 5.6.1996 / 17:08:30 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1202
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1203
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1204
!PopUpMenu methodsFor:'deactivation'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1205
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1206
hide
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1207
    "hide the menu - if there are any pop-up-submenus, hide them also"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1208
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1209
    menuView hideSubmenu.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1210
    super hide.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1211
    menuView superMenu notNil ifTrue:[
1057
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1212
        menuView superMenu regainControl
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1213
    ].
1057
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1214
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1215
    "Modified: 25.2.1997 / 22:11:53 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1216
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1217
70
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
  1218
!PopUpMenu methodsFor:'event handling'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1219
161
claus
parents: 137
diff changeset
  1220
buttonMotion:state x:x y:y
1150
ce8842029d20 care for late motion events
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1221
    |p superMenu sensor|
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1222
161
claus
parents: 137
diff changeset
  1223
    state == 0 ifTrue:[^ self].
1623
1fde415aabf3 ignore motion event if no button is pressed.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
  1224
1150
ce8842029d20 care for late motion events
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1225
    (sensor := self sensor) isNil ifTrue:[^ self].
1623
1fde415aabf3 ignore motion event if no button is pressed.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
  1226
    "any-button ?"
1fde415aabf3 ignore motion event if no button is pressed.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
  1227
    sensor anyButtonPressed ifFalse:[^ self].
1150
ce8842029d20 care for late motion events
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1228
    (sensor hasButtonMotionEventFor:self) ifTrue:[^ self].
161
claus
parents: 137
diff changeset
  1229
1859
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1230
    ((x >= 0) 
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1231
    and:[x < width
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1232
    and:[y >= 0
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1233
    and:[y < height]]]) ifTrue:[
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1234
        "/ inside me
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1235
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1236
        (x >= margin 
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1237
        and:[x < (width-margin)
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1238
        and:[y >= margin
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1239
        and:[y < (height-margin)]]]) ifTrue:[
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1240
            "/ inside my menuView
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1241
1057
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1242
            hideOnRelease := true.
1859
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1243
            p := device translatePoint:(x @ y)
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1244
                                  from:drawableId
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1245
                                    to:(menuView id).
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1246
        
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1247
            menuView buttonMotion:state x:p x y:p y.
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1248
        ].
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1249
        ^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1250
    ].
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1251
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1252
    "outside of myself"
70
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
  1253
    superMenu := menuView superMenu.
14443a9ea4ec *** empty log message ***
claus
parents: 63
diff changeset
  1254
    superMenu notNil ifTrue:[
1057
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1255
        p := device translatePoint:(x @ y)
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1256
                              from:drawableId
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1257
                                to:(menuView superMenu id).
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1258
        superMenu buttonMotion:state x:p x y:p y
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1259
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1260
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1261
    menuView subMenuShown isNil ifTrue:[
1057
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1262
        menuView pointerLeave:state.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1263
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1264
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1265
    hideOnLeave ifTrue:[
1057
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1266
        self hide
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
  1267
    ].
1057
220f818b0577 ignore motions if more are pending
Claus Gittinger <cg@exept.de>
parents: 1056
diff changeset
  1268
1623
1fde415aabf3 ignore motion event if no button is pressed.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
  1269
    "Modified: / 28.7.1998 / 16:00:15 / cg"
1859
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1270
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1271
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1272
105
3d064ba4a0cc *** empty log message ***
claus
parents: 96
diff changeset
  1273
buttonPress:button x:x y:y
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1274
    hideOnRelease := true.
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  1275
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1276
    ((x >= 0) and:[x < width]) ifTrue:[
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1277
        ((y >= 0) and:[y < height]) ifTrue:[
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1278
            menuView buttonPress:button x:x y:y.
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1279
            ^ self
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1280
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 96
diff changeset
  1281
    ].
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1282
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  1283
    "Modified: 22.1.1997 / 17:38:14 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 96
diff changeset
  1284
!
3d064ba4a0cc *** empty log message ***
claus
parents: 96
diff changeset
  1285
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1286
buttonRelease:button x:x y:y
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1287
    realized ifFalse:[^ self].
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1288
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1289
    "/
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1290
    "/ detect short click - stay open if this is one
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1291
    "/
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1292
    (OperatingSystem 
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1293
        millisecondTimeDeltaBetween:(Time millisecondClockValue)
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1294
                                and:mapTime) > 200 ifFalse:[
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1295
        hideOnRelease := false
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1296
    ].
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1297
105
3d064ba4a0cc *** empty log message ***
claus
parents: 96
diff changeset
  1298
    hideOnRelease ifFalse:[
425
9d44d3ff44a0 avoid recursion trouble
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
  1299
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 96
diff changeset
  1300
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 96
diff changeset
  1301
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1302
    (x < 0 
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1303
    or:[x >= width
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1304
    or:[y < 0
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1305
    or:[y >= height]]]) ifTrue:[
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1306
         "/   
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1307
         "/ released outside of mySelf
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1308
         "/
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1309
        menuView superMenu notNil ifTrue:[
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1310
            menuView superMenu hideSubmenu
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1311
        ] ifFalse:[
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1312
            self hide
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1313
        ].
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1314
        ^ self
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1315
    ].
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1316
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1317
465
b473edeab54e can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
  1318
"/    menuView superMenu notNil ifTrue:[
b473edeab54e can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
  1319
"/        menuView superMenu submenuTriggered 
b473edeab54e can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
  1320
"/    ].
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1321
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  1322
    menuView buttonRelease:button x:x y:y.
425
9d44d3ff44a0 avoid recursion trouble
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
  1323
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1324
    "Modified: 8.3.1996 / 14:17:18 / cg"
112
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
  1325
!
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
  1326
81633ba1bf40 *** empty log message ***
claus
parents: 110
diff changeset
  1327
keyPress:key x:x y:y
491
7b376aaa06d5 resources
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
  1328
    <resource: #keyboard (#Tab)>
7b376aaa06d5 resources
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
  1329
1403
ddc59498d1c3 toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1330
"/    (x isNil or:[x == 0]) ifTrue:[
ddc59498d1c3 toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1331
"/        "/ already redelegated
ddc59498d1c3 toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1332
"/        ^ self
ddc59498d1c3 toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1333
"/    ].
425
9d44d3ff44a0 avoid recursion trouble
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
  1334
348
2925bbd4f346 dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  1335
    key == #Tab ifTrue:[
2925bbd4f346 dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  1336
        self hide.
2925bbd4f346 dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  1337
        super keyPress:key x:x y:y.
2925bbd4f346 dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  1338
    ] ifFalse:[
1408
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1339
        x == 0 ifTrue:[
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1340
            menuView keyPress:key x:nil y:nil.
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1341
        ] ifFalse:[
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1342
            x notNil ifTrue:[
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1343
                "/ already redelegated
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1344
                menuView keyPress:key x:x y:y.
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1345
            ].
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1346
        ]
348
2925bbd4f346 dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  1347
    ].
2925bbd4f346 dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
  1348
1408
61d42fa7dafd care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
  1349
    "Modified: / 6.12.1997 / 01:53:08 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1350
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1351
342
ddbe4e8d6e9f check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1352
mapped
ddbe4e8d6e9f check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1353
    super mapped.
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1354
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1355
    "/
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1356
    "/ check if a button is pressed when mapped;
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1357
    "/ if not, change my hide-strategy
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1358
    "/
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1359
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1360
"/    device buttonStates == 0 ifTrue:[
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1361
"/        hideOnRelease := false
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1362
"/    ].
342
ddbe4e8d6e9f check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1363
ddbe4e8d6e9f check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1364
    "Created: 9.2.1996 / 19:56:20 / cg"
497
072d3b8507fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
  1365
    "Modified: 8.3.1996 / 13:42:15 / cg"
342
ddbe4e8d6e9f check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1366
!
ddbe4e8d6e9f check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1367
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1368
pointerEnter:state x:x y:y
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1369
    "catch quick release of button"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1370
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1371
    hideOnLeave ifTrue:[
1859
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1372
        state == 0 ifTrue:[
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1373
            self hide
acd3ca6d027b do not forward motion-events if within my margin.
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  1374
        ].
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1375
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1376
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1377
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1378
pointerLeave:state
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1379
"/    menuView pointerLeave:state.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1380
"/    hideOnLeave ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1381
"/        self hide
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1382
"/    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1383
"/    menuView superMenu notNil ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1384
"/        menuView superMenu regainControl
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1385
"/    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1386
! !
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1387
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1388
!PopUpMenu methodsFor:'initialization'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1389
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1390
initEvents
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1391
    super initEvents.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1392
    self enableEnterLeaveEvents.
495
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
  1393
"/    self enableMotionEvents.
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
  1394
d993f23ea658 fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents: 491
diff changeset
  1395
    "Modified: 7.3.1996 / 14:17:42 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1396
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1397
1861
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1398
initStyle
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1399
    <resource: #style (#'popup.hideOnRelease'
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1400
                       #'popup.level'
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1401
                       #'popup.borderWidth'
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1402
                       )>
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1403
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1404
    |lvl bw|
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1405
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1406
    super initStyle.
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1407
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1408
    (lvl := styleSheet at:#'popup.level') notNil ifTrue:[
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1409
        self level:lvl.
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1410
    ].
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1411
    (bw := styleSheet at:#'popup.borderWidth') notNil ifTrue:[
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1412
        self borderWidth:bw
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1413
    ].
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1414
    defaultHideOnRelease := styleSheet at:#'popup.hideOnRelease' default:true
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1415
!
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1416
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1417
initialize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1418
    super initialize.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1419
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1420
    memorize := true.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1421
    hideOnLeave := false.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1422
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1423
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1424
!PopUpMenu methodsFor:'menuview messages'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1425
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1426
doesNotUnderstand:aMessage
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1427
    "forward all menu-view messages"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1428
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1429
    (menuView respondsTo:(aMessage selector)) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1430
	^ aMessage sendTo:menuView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1431
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1432
    ^ super doesNotUnderstand:aMessage
1404
1085b9e9fb09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
  1433
!
1085b9e9fb09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
  1434
1085b9e9fb09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
  1435
regainControl
1085b9e9fb09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
  1436
    device ungrabPointer.
1085b9e9fb09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
  1437
    device ungrabKeyboard.
1442
7dfbc21dfdc6 Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 1408
diff changeset
  1438
    shown ifTrue:[
7dfbc21dfdc6 Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 1408
diff changeset
  1439
        device grabPointerInView:self.
7dfbc21dfdc6 Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 1408
diff changeset
  1440
        device grabKeyboardInView:self.
7dfbc21dfdc6 Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 1408
diff changeset
  1441
    ].
1404
1085b9e9fb09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
  1442
1442
7dfbc21dfdc6 Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 1408
diff changeset
  1443
    "Modified: / 20.11.1997 / 00:32:32 / cg"
7dfbc21dfdc6 Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents: 1408
diff changeset
  1444
    "Modified: / 2.2.1998 / 23:52:28 / stefan"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1445
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1446
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1447
!PopUpMenu methodsFor:'private accessing'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1448
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1449
menu:aMenuView
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1450
    "set the actual menu"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1451
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1452
    self obsoleteMethodWarning:'use #menuView:'.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1453
    self menuView:aMenuView
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1454
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1455
    "Modified: 25.2.1997 / 20:52:08 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1456
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1457
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1458
menuView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1459
    "return the actual menu"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1460
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1461
    ^ menuView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1462
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1463
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1464
menuView:aMenu
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1465
    "set the actual menu"
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1466
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1467
    menuView := aMenu.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1468
    menuView origin:(margin @ margin).
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1469
    menuView borderWidth:0.
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1470
    menuView masterView:self
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1471
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1472
    "Created: 25.2.1997 / 20:51:42 / cg"
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1473
!
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1474
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1475
superMenu:aMenu
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1476
    "set the superMenu"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1477
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1478
    menuView superMenu:aMenu
1056
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1479
ef4c9dc26b37 #menu: -> #menuView:
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1480
    "Modified: 25.2.1997 / 20:52:20 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1481
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1482
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1483
!PopUpMenu methodsFor:'realization'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1484
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1485
fixSize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1486
    "called right before the view is made visible.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1487
     adjust my size to the size of the actual menu"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1488
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1489
    |extra newWidth newHeight|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1490
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1491
    extra := margin * 2.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1492
    menuView resizeIfChanged.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1493
    newWidth := menuView width + extra.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1494
    newHeight := menuView height + extra.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1495
    ((newWidth ~~ width) or:[newHeight ~~ height]) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1496
	self extent:(menuView width + extra) @ (menuView height + extra)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1497
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1498
    super fixSize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1499
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1500
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1501
realize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1502
    menuView deselectWithoutRedraw.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1503
    super realize.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1504
    hideOnRelease := defaultHideOnRelease.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1505
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1506
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1507
!PopUpMenu class methodsFor:'documentation'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1508
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1509
version
1861
a582b6c0809d take level & borderWidth from popup.level and
Claus Gittinger <cg@exept.de>
parents: 1859
diff changeset
  1510
    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.79 1999-04-24 12:02:25 cg Exp $'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1511
! !