EnterBox2.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Nov 1995 03:26:58 +0100
changeset 197 00927189c882
parent 174 d80a6cc3f9b2
child 355 a55f62047156
permissions -rw-r--r--
checkin from browser
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) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
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
EnterBox subclass:#EnterBox2
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    14
	 instanceVariableNames:'okButton2 okAction2'
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    15
	 classVariableNames:''
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    16
	 poolDictionaries:''
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    17
	 category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    20
!EnterBox2 class methodsFor:'instance creation'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    21
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    22
title:titleString okText1:text1 okText2:text2 abortText:abortText
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    23
		  action1:block1 action2:block2
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    24
    "create and return a new EnterBox-with-2 buttons
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    25
     and define its text, button-labels and actions"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    26
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    27
    ^ (super title:titleString 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    28
	    okText:text1 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    29
	 abortText:abortText
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    30
	    action:block1) okText2:text2 action2:block2
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    31
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    32
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    33
!EnterBox2 class methodsFor:'documentation '!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    34
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    35
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    36
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    37
 COPYRIGHT (c) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
    38
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    39
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    40
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    41
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    42
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    43
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    44
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    45
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    46
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    47
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    48
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    49
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    50
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    51
    An EnterBox2 is like an EnterBox but with 2 action buttons.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    52
    This is used (for example) in the search-boxes, where two ok-buttons
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    53
    'find-previous' and 'find-next' are needed in addition to the abort button.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    54
    The protocol is like that of EnterBox, the additional buttons label
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    55
    can be set with 'okText2:aString' and its action with 'action2:aBlock'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    56
"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    57
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    58
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    59
version
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    60
    ^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.13 1995-11-23 02:25:05 cg Exp $'
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    61
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    62
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    63
!EnterBox2 methodsFor:'accessing'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    64
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    65
action2:aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    66
    "set the action to be performed when user presses the 2nd ok-button;
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    67
     aBlock must be nil or a block with one argument "
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    68
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    69
    okAction2 := aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    70
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    71
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    72
okText2:aString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    73
    "set the text to be displayed in the 2nd ok-button"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    74
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    75
    aString ~= okButton2 label ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    76
	okButton2 label:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    77
	okButton2 resize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    78
	shown ifTrue:[self resize]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    79
    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    80
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    81
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    82
okText2:aString action2:aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    83
    "set the text to be displayed in the 2nd ok-button,
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    84
     and its action"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    85
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    86
    self okText2:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    87
    okAction2 := aBlock
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    88
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    89
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    90
!EnterBox2 methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    91
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    92
focusSequence
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
    ^ Array with:enterField with:abortButton with:okButton with:okButton2 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    95
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    96
initialize
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    97
    super initialize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    98
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
    99
    "
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   100
     add a second ok-button
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   101
    "
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   102
    okButton2 := Button okButtonIn:buttonPanel.
95
7535cfca9509 *** empty log message ***
claus
parents: 77
diff changeset
   103
    okButton2 model:self; change:#ok2Pressed.
7535cfca9509 *** empty log message ***
claus
parents: 77
diff changeset
   104
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   105
    "
77
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   106
     the old (see superclass) ok-button is no longer a return-button
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   107
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   108
    okButton isReturnButton:false.
48
eabeb474d989 changed cursors
claus
parents: 38
diff changeset
   109
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   110
    enterField leaveAction:[:key | self ok2Pressed]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   111
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   112
8
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   113
!EnterBox2 methodsFor:'realization'!
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   114
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   115
positionOffset
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   116
    "return the delta, by which the box should be displayed
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   117
     from the mouse pointer. Value returned here makes
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   118
     okButton appear under the cursor"
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   119
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   120
    buttonPanel setChildPositionsIfChanged.
8
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   121
    ^ (okButton2 originRelativeTo:self) + (okButton2 extent // 2)
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   122
! !
82e87dc3540e *** empty log message ***
claus
parents: 5
diff changeset
   123
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   124
!EnterBox2 methodsFor:'user interaction'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   125
77
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   126
keyPress:aKey x:x y:y
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   127
    "return-key dublicates ok-function if acceptReturnAsOK is true"
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   128
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   129
    acceptReturnAsOK ifTrue:[
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   130
	(aKey == #Return) ifTrue:[^ self ok2Pressed]
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   131
    ].
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   132
    super keyPress:aKey x:x y:y
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   133
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   134
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   135
ok2Pressed
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   136
    "user pressed 2nd ok button - evaluate action"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   137
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   138
    okButton2 turnOffWithoutRedraw.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   139
    self hideAndEvaluate:okAction2
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   140
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   141