EditField.st
author Claus Gittinger <cg@exept.de>
Tue, 16 Jan 1996 03:04:32 +0100
changeset 289 82d20a3e2fe8
parent 279 b9fa9180aca4
child 290 f539121393b1
permissions -rw-r--r--
dont grab if no menu pulled
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) 1990 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
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
EditTextView subclass:#EditField
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    14
	instanceVariableNames:'leaveAction enabled enableAction crAction tabAction converter
209
7a6db7fac566 dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    15
		leaveKeys immediateAccept acceptOnLeave acceptOnReturn
7a6db7fac566 dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    16
		lengthLimit entryCompletionBlock passwordCharacter
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    17
		cursorMovementWhenUpdating enableChannel'
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    18
	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
209
7a6db7fac566 dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    19
		DefaultSelectionForegroundColor DefaultSelectionBackgroundColor
7a6db7fac566 dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    20
		DefaultFont'
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    21
	poolDictionaries:''
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    22
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    23
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    24
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    25
!EditField class methodsFor:'documentation'!
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    26
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    27
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    28
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    29
 COPYRIGHT (c) 1990 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
    30
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    31
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    32
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    33
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    35
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    36
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    37
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    38
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    39
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    40
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    41
documentation
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    42
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    43
    an editable text-field. Realized by using an EditTextView,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    44
    and forcing its size to 1 line - disabling cursor movement
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    45
    in the vertical direction.
121
claus
parents: 120
diff changeset
    46
claus
parents: 120
diff changeset
    47
    Instance variables:
claus
parents: 120
diff changeset
    48
claus
parents: 120
diff changeset
    49
      leaveAction    <Block | nil>              if non-nil, this is evaluated with
claus
parents: 120
diff changeset
    50
						the key (#Return, #CursorUp etc.) when
claus
parents: 120
diff changeset
    51
						the field is left via keyboard keys.
claus
parents: 120
diff changeset
    52
						(fieldGroups use this to decide which
claus
parents: 120
diff changeset
    53
						 field has to be enabled next)
claus
parents: 120
diff changeset
    54
claus
parents: 120
diff changeset
    55
      enabled        <Boolean>                  if false, input is ignored.
claus
parents: 120
diff changeset
    56
125
claus
parents: 122
diff changeset
    57
      enableAction   <Block | nil>              action performed if the field is
claus
parents: 122
diff changeset
    58
						enabled via an explicit click.
claus
parents: 122
diff changeset
    59
						(this is used by the group to
claus
parents: 122
diff changeset
    60
						 set the active field to the clicked upon field)
121
claus
parents: 120
diff changeset
    61
claus
parents: 120
diff changeset
    62
      crAction       <Block | nil>              if non-nil, keyboard input of a cr are not
claus
parents: 120
diff changeset
    63
						handled specially, instead this block is evaluated
claus
parents: 120
diff changeset
    64
						(however, this block can perform additional checks and send
claus
parents: 120
diff changeset
    65
						 a #accept then)
claus
parents: 120
diff changeset
    66
claus
parents: 120
diff changeset
    67
      tabAction      <Block | nil>              if non-nil, keyboard input of a tab character
claus
parents: 120
diff changeset
    68
						is not entered into the text, instead this block
claus
parents: 120
diff changeset
    69
						is evaluated.
claus
parents: 120
diff changeset
    70
claus
parents: 120
diff changeset
    71
      converter      <PrintConverter | nil>     if non-nil, this is supposed to convert between
claus
parents: 120
diff changeset
    72
						the object and its printed representation.
claus
parents: 120
diff changeset
    73
						Defaults to nil i.e. assume that strings are edited.
claus
parents: 120
diff changeset
    74
claus
parents: 120
diff changeset
    75
      leaveKeys      <Collection>               keys which are interpreted as 'leving the field'
122
claus
parents: 121
diff changeset
    76
125
claus
parents: 122
diff changeset
    77
      immediateAccept   <Boolean>               if true, every change of the text is immediately
claus
parents: 122
diff changeset
    78
						forwarded to the model/acceptBlock. If false,
claus
parents: 122
diff changeset
    79
						the changed value is only stored in the model
claus
parents: 122
diff changeset
    80
						if the field is left or accepted.
claus
parents: 122
diff changeset
    81
						Default is false.
122
claus
parents: 121
diff changeset
    82
claus
parents: 121
diff changeset
    83
      acceptOnLeave  <Boolean>                  if true, leaving the field (via cursor keys)
claus
parents: 121
diff changeset
    84
						automatically accepts the value into the model.
130
claus
parents: 128
diff changeset
    85
						Default is true.
122
claus
parents: 121
diff changeset
    86
claus
parents: 121
diff changeset
    87
      acceptOnReturn <Boolean>                  if true, leaving the field via return
claus
parents: 121
diff changeset
    88
						automatically accepts the value into the model.
130
claus
parents: 128
diff changeset
    89
						Default is true.
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    90
"
120
claus
parents: 118
diff changeset
    91
!
claus
parents: 118
diff changeset
    92
claus
parents: 118
diff changeset
    93
examples 
claus
parents: 118
diff changeset
    94
"
122
claus
parents: 121
diff changeset
    95
    see more examples in EnterFieldGroup>>examples.
claus
parents: 121
diff changeset
    96
claus
parents: 121
diff changeset
    97
claus
parents: 121
diff changeset
    98
    basic field in a view:
120
claus
parents: 118
diff changeset
    99
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   100
        |top field|
120
claus
parents: 118
diff changeset
   101
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   102
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   103
        top extent:200@100.
120
claus
parents: 118
diff changeset
   104
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   105
        field := EditField origin:0.0@0.0 in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   106
        field width:1.0.        'let its height as-is'.
120
claus
parents: 118
diff changeset
   107
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   108
        top open
120
claus
parents: 118
diff changeset
   109
122
claus
parents: 121
diff changeset
   110
125
claus
parents: 122
diff changeset
   111
    forward input in topView to the field:
claus
parents: 122
diff changeset
   112
    (currently, the field does not know this - therefore,
claus
parents: 122
diff changeset
   113
     its been told here ... this may change)
122
claus
parents: 121
diff changeset
   114
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   115
        |top field|
122
claus
parents: 121
diff changeset
   116
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   117
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   118
        top extent:200@100.
122
claus
parents: 121
diff changeset
   119
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   120
        field := EditField origin:0.0@0.0 in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   121
        field width:1.0.        'let its height as-is'.
122
claus
parents: 121
diff changeset
   122
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   123
        top delegate:(KeyboardForwarder toView:field).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   124
        field hasKeyboardFocus:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   125
        top open
122
claus
parents: 121
diff changeset
   126
claus
parents: 121
diff changeset
   127
125
claus
parents: 122
diff changeset
   128
    to make it look better: set some inset:
120
claus
parents: 118
diff changeset
   129
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   130
        |top field|
120
claus
parents: 118
diff changeset
   131
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   132
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   133
        top extent:200@100.
120
claus
parents: 118
diff changeset
   134
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   135
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   136
        field width:1.0.        'let its height as-is'.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   137
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   138
              rightInset:ViewSpacing.
120
claus
parents: 118
diff changeset
   139
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   140
        top open
120
claus
parents: 118
diff changeset
   141
122
claus
parents: 121
diff changeset
   142
120
claus
parents: 118
diff changeset
   143
    give it an initial contents:
claus
parents: 118
diff changeset
   144
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   145
        |top field|
120
claus
parents: 118
diff changeset
   146
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   147
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   148
        top extent:200@100.
120
claus
parents: 118
diff changeset
   149
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   150
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   151
        field width:1.0.       
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   152
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   153
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   154
        field editValue:'hello world'.
120
claus
parents: 118
diff changeset
   155
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   156
        top open
120
claus
parents: 118
diff changeset
   157
122
claus
parents: 121
diff changeset
   158
125
claus
parents: 122
diff changeset
   159
    have it preselected:
120
claus
parents: 118
diff changeset
   160
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   161
        |top field|
120
claus
parents: 118
diff changeset
   162
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   163
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   164
        top extent:200@100.
120
claus
parents: 118
diff changeset
   165
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   166
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   167
        field width:1.0.     
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   168
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   169
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   170
        field editValue:'hello world' selected:true.
120
claus
parents: 118
diff changeset
   171
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   172
        top open
120
claus
parents: 118
diff changeset
   173
122
claus
parents: 121
diff changeset
   174
120
claus
parents: 118
diff changeset
   175
    have part of it preselected:
claus
parents: 118
diff changeset
   176
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   177
        |top field|
120
claus
parents: 118
diff changeset
   178
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   179
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   180
        top extent:200@100.
120
claus
parents: 118
diff changeset
   181
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   182
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   183
        field width:1.0.     
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   184
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   185
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   186
        field editValue:'hello world';
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   187
              selectFromCharacterPosition:1 to:5.
120
claus
parents: 118
diff changeset
   188
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   189
        top open
120
claus
parents: 118
diff changeset
   190
122
claus
parents: 121
diff changeset
   191
125
claus
parents: 122
diff changeset
   192
    set a size limit:
claus
parents: 122
diff changeset
   193
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   194
        |top field|
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   195
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   196
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   197
        top extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   198
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   199
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   200
        field width:1.0.     
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   201
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   202
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   203
        field editValue:'hello';
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   204
              maxChars:8.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   205
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   206
        top open
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   207
125
claus
parents: 122
diff changeset
   208
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   209
    enable / disable:
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   210
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   211
        |top panel check field ena|
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   212
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   213
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   214
        top extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   215
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   216
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   217
        panel horizontalLayout:#leftSpace.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   218
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   219
        check := CheckBox label:'enable' in:panel.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   220
        check turnOn.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   221
        check action:[:onOff | onOff ifTrue:[field enable] ifFalse:[field disable]].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   222
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   223
        panel add:(View new height:30).
125
claus
parents: 122
diff changeset
   224
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   225
        field := EditField in:panel.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   226
        field width:1.0.     
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   227
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   228
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   229
        field editValue:'hello'.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   230
        
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   231
        top open
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   232
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   233
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   234
    enable / disable using a channel:
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   235
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   236
        |top panel check field ena|
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   237
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   238
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   239
        top extent:200@100.
125
claus
parents: 122
diff changeset
   240
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   241
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   242
        panel horizontalLayout:#leftSpace.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   243
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   244
        ena := true asValue.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   245
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   246
        check := CheckBox label:'enable' in:panel.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   247
        check model:ena.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   248
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   249
        panel add:(View new height:30).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   250
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   251
        field := EditField in:panel.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   252
        field enableChannel:ena.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   253
        field width:1.0.     
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   254
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   255
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   256
        field editValue:'hello'.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   257
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   258
        top open
125
claus
parents: 122
diff changeset
   259
claus
parents: 122
diff changeset
   260
121
claus
parents: 120
diff changeset
   261
    use a converter:
125
claus
parents: 122
diff changeset
   262
      - numbers (default to 0):
121
claus
parents: 120
diff changeset
   263
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   264
        |top field|
121
claus
parents: 120
diff changeset
   265
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   266
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   267
        top extent:200@100.
121
claus
parents: 120
diff changeset
   268
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   269
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   270
        field width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   271
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   272
              rightInset:ViewSpacing.
121
claus
parents: 120
diff changeset
   273
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   274
        field converter:(PrintConverter new initForNumber).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   275
        field editValue:1234.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   276
        field acceptAction:[:value | Transcript showCr:value].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   277
        field crAction:[field accept. top destroy].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   278
        top open.
121
claus
parents: 120
diff changeset
   279
claus
parents: 120
diff changeset
   280
      - dates:
claus
parents: 120
diff changeset
   281
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   282
        |top field|
121
claus
parents: 120
diff changeset
   283
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   284
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   285
        top extent:200@100.
121
claus
parents: 120
diff changeset
   286
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   287
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   288
        field width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   289
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   290
              rightInset:ViewSpacing.
121
claus
parents: 120
diff changeset
   291
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   292
        field converter:(PrintConverter new initForDate).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   293
        field editValue:Date today.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   294
        field acceptAction:[:value | Transcript showCr:value class name , ' ' , value printString].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   295
        field crAction:[field accept. top destroy].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   296
        top open.
121
claus
parents: 120
diff changeset
   297
122
claus
parents: 121
diff changeset
   298
125
claus
parents: 122
diff changeset
   299
    setting immediateAccept, makes the field update with every key:
claus
parents: 122
diff changeset
   300
claus
parents: 122
diff changeset
   301
      - immediate accept numbers, defaulting to nil:
121
claus
parents: 120
diff changeset
   302
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   303
        |top field|
121
claus
parents: 120
diff changeset
   304
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   305
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   306
        top extent:200@100.
121
claus
parents: 120
diff changeset
   307
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   308
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   309
        field width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   310
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   311
              rightInset:ViewSpacing.
121
claus
parents: 120
diff changeset
   312
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   313
        field converter:(PrintConverter new initForNumberOrNil).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   314
        field immediateAccept:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   315
        field editValue:1234.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   316
        field acceptAction:[:value | Transcript showCr:value].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   317
        field crAction:[field accept. top destroy].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   318
        top open.
121
claus
parents: 120
diff changeset
   319
122
claus
parents: 121
diff changeset
   320
127
claus
parents: 125
diff changeset
   321
claus
parents: 125
diff changeset
   322
120
claus
parents: 118
diff changeset
   323
    use a model:
claus
parents: 118
diff changeset
   324
    (see changing model value in inspector when return is pressed in the field)
claus
parents: 118
diff changeset
   325
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   326
        |top field model|
120
claus
parents: 118
diff changeset
   327
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   328
        model := 'hello world' asValue.
120
claus
parents: 118
diff changeset
   329
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   330
        top := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   331
        top extent:200@100.
120
claus
parents: 118
diff changeset
   332
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   333
        field := EditField origin:0.0@ViewSpacing in:top.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   334
        field width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   335
        field leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   336
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   337
        field model:model.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   338
        field acceptOnReturn:true.
120
claus
parents: 118
diff changeset
   339
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   340
        top open.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   341
        model inspect.
121
claus
parents: 120
diff changeset
   342
122
claus
parents: 121
diff changeset
   343
127
claus
parents: 125
diff changeset
   344
    two views on the same model (each accepts on return):
121
claus
parents: 120
diff changeset
   345
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   346
        |top1 top2 field1 field2 model|
121
claus
parents: 120
diff changeset
   347
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   348
        model := 'hello world' asValue.
121
claus
parents: 120
diff changeset
   349
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   350
        top1 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   351
        top1 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   352
        field1 := EditField origin:0.0@ViewSpacing in:top1.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   353
        field1 width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   354
        field1 leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   355
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   356
        field1 model:model.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   357
        field1 acceptOnReturn:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   358
        top1 open.
121
claus
parents: 120
diff changeset
   359
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   360
        top2 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   361
        top2 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   362
        field2 := EditField origin:0.0@ViewSpacing in:top2.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   363
        field2 width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   364
        field2 leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   365
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   366
        field2 model:model.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   367
        field2 acceptOnReturn:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   368
        top2 open.
121
claus
parents: 120
diff changeset
   369
127
claus
parents: 125
diff changeset
   370
    two views on the same model (no accept on return):
claus
parents: 125
diff changeset
   371
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   372
        |top1 top2 field1 field2 model|
127
claus
parents: 125
diff changeset
   373
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   374
        model := 'hello world' asValue.
127
claus
parents: 125
diff changeset
   375
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   376
        top1 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   377
        top1 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   378
        field1 := EditField origin:0.0@ViewSpacing in:top1.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   379
        field1 width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   380
        field1 leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   381
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   382
        field1 model:model; acceptOnReturn:false.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   383
        top1 open.
127
claus
parents: 125
diff changeset
   384
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   385
        top2 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   386
        top2 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   387
        field2 := EditField origin:0.0@ViewSpacing in:top2.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   388
        field2 width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   389
        field2 leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   390
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   391
        field2 model:model; acceptOnReturn:false.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   392
        top2 open.
127
claus
parents: 125
diff changeset
   393
125
claus
parents: 122
diff changeset
   394
    with immediate accept:
claus
parents: 122
diff changeset
   395
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   396
        |top1 top2 field1 field2 model|
125
claus
parents: 122
diff changeset
   397
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   398
        model := 'hello world' asValue.
125
claus
parents: 122
diff changeset
   399
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   400
        top1 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   401
        top1 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   402
        field1 := EditField origin:0.0@ViewSpacing in:top1.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   403
        field1 width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   404
        field1 leftInset:ViewSpacing; rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   405
        field1 model:model; immediateAccept:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   406
        top1 open.
125
claus
parents: 122
diff changeset
   407
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   408
        top2 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   409
        top2 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   410
        field2 := EditField origin:0.0@ViewSpacing in:top2.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   411
        field2 width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   412
        field2 leftInset:ViewSpacing; rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   413
        field2 model:model; immediateAccept:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   414
        top2 open.
122
claus
parents: 121
diff changeset
   415
121
claus
parents: 120
diff changeset
   416
    just an example; a checkBox and an editField on the same model:
claus
parents: 120
diff changeset
   417
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   418
        |top1 top2 field1 box model|
121
claus
parents: 120
diff changeset
   419
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   420
        model := false asValue.
121
claus
parents: 120
diff changeset
   421
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   422
        top1 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   423
        top1 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   424
        field1 := EditField origin:0.0@ViewSpacing in:top1.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   425
        field1 width:1.0.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   426
        field1 leftInset:ViewSpacing;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   427
              rightInset:ViewSpacing.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   428
        field1 converter:(PrintConverter new initForYesNo).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   429
        field1 model:model.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   430
        top1 open.
121
claus
parents: 120
diff changeset
   431
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   432
        top2 := StandardSystemView new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   433
        top2 extent:200@100.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   434
        box := CheckBox on:model.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   435
        box label:'on/off'.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   436
        top2 add:box.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   437
        top2 open.
121
claus
parents: 120
diff changeset
   438
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   439
        model inspect.
125
claus
parents: 122
diff changeset
   440
claus
parents: 122
diff changeset
   441
claus
parents: 122
diff changeset
   442
    connecting fields:
claus
parents: 122
diff changeset
   443
    update field2 wehenever field1 is changed.
claus
parents: 122
diff changeset
   444
    (normally, the processing below (xChanged) is done in your application
claus
parents: 122
diff changeset
   445
     class, or in a complex model. For the demonstration below, we use
claus
parents: 122
diff changeset
   446
     a Plug to simulate the protocol.)
claus
parents: 122
diff changeset
   447
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   448
        |application top field1 field2 value1 value2|
125
claus
parents: 122
diff changeset
   449
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   450
        application := Plug new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   451
        application respondTo:#value1Changed
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   452
                         with:[value2 value:(value1 value isNil ifTrue:[nil]
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   453
                                                                ifFalse:[value1 value squared])].
125
claus
parents: 122
diff changeset
   454
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   455
        value1 := 1 asValue.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   456
        value2 := 1 asValue.
125
claus
parents: 122
diff changeset
   457
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   458
        top := Dialog new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   459
        top extent:200@200.
125
claus
parents: 122
diff changeset
   460
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   461
        (top addTextLabel:'some number:') layout:#left.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   462
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   463
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   464
        (top addInputFieldOn:value1 tabable:false) 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   465
            converter:(PrintConverter new initForNumberOrNil);
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   466
            immediateAccept:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   467
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   468
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   469
        (top addTextLabel:'squared:') layout:#left.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   470
        top addVerticalSpace.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   471
        (top addInputFieldOn:value2 tabable:false) 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   472
            converter:(PrintConverter new initForNumberOrNil).
125
claus
parents: 122
diff changeset
   473
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   474
        value1 onChangeSend:#value1Changed to:application.
125
claus
parents: 122
diff changeset
   475
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   476
        top openModeless.
125
claus
parents: 122
diff changeset
   477
claus
parents: 122
diff changeset
   478
claus
parents: 122
diff changeset
   479
    two-way connect:
claus
parents: 122
diff changeset
   480
    each field updates the other (notice, that we have to turn off
claus
parents: 122
diff changeset
   481
    onChange: notification, to avoid an endless notification cycle)
claus
parents: 122
diff changeset
   482
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   483
        |application top field1 field2 value1 value2|
125
claus
parents: 122
diff changeset
   484
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   485
        application := Plug new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   486
        application respondTo:#value1Changed
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   487
                         with:[value2 retractInterestsFor:application.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   488
                               value2 value:(value1 value isNil ifTrue:[nil]
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   489
                                                                ifFalse:[value1 value squared]).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   490
                               value2 onChangeSend:#value2Changed to:application.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   491
                              ].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   492
        application respondTo:#value2Changed
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   493
                         with:[value1 retractInterestsFor:application.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   494
                               value1 value:(value2 value isNil ifTrue:[nil]
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   495
                                                                ifFalse:[value2 value sqrt]).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   496
                               value1 onChangeSend:#value1Changed to:application.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   497
                              ].
125
claus
parents: 122
diff changeset
   498
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   499
        value1 := 1 asValue.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   500
        value2 := 1 asValue.
125
claus
parents: 122
diff changeset
   501
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   502
        top := Dialog new.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   503
        top extent:200@200.
125
claus
parents: 122
diff changeset
   504
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   505
        (top addTextLabel:'some number:') layout:#left.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   506
        top addVerticalSpace.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   507
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   508
        (top addInputFieldOn:value1 tabable:false) 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   509
            converter:(PrintConverter new initForNumberOrNil);
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   510
            immediateAccept:true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   511
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   512
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   513
        (top addTextLabel:'squared:') layout:#left.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   514
        top addVerticalSpace.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   515
        (top addInputFieldOn:value2 tabable:false) 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   516
            converter:(PrintConverter new initForNumberOrNil);
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   517
            immediateAccept:true.
125
claus
parents: 122
diff changeset
   518
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   519
        value1 onChangeSend:#value1Changed to:application.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   520
        value2 onChangeSend:#value2Changed to:application.
125
claus
parents: 122
diff changeset
   521
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   522
        top openModeless.
120
claus
parents: 118
diff changeset
   523
"
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
   524
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   525
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   526
!EditField class methodsFor:'defaults'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   527
125
claus
parents: 122
diff changeset
   528
defaultLeaveKeys
128
claus
parents: 127
diff changeset
   529
    "return the set of keys which are taken as leave-keys.
claus
parents: 127
diff changeset
   530
     If the field is in an enterFieldGroup, all leave keys will be
claus
parents: 127
diff changeset
   531
     forwarded to the group and possible step to the next/previous field.
claus
parents: 127
diff changeset
   532
     Also, if acceptOnLeave is true, leave keys will store the current
claus
parents: 127
diff changeset
   533
     value into their model (if any)"
claus
parents: 127
diff changeset
   534
125
claus
parents: 122
diff changeset
   535
    ^ #(Return CursorUp CursorDown Next Previous Accept)
claus
parents: 122
diff changeset
   536
!
claus
parents: 122
diff changeset
   537
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   538
defaultNumberOfLines
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   539
    "the number of lines in the field"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   540
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   541
    ^ 1
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   542
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   543
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   544
updateStyleCache
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   545
    DefaultForegroundColor := StyleSheet colorAt:'editFieldForegroundColor' default:Black.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   546
    DefaultBackgroundColor := StyleSheet colorAt:'editFieldBackgroundColor' default:White.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   547
    DefaultSelectionForegroundColor := StyleSheet colorAt:'editFieldSelectionForegroundColor' default:DefaultBackgroundColor.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   548
    DefaultSelectionBackgroundColor := StyleSheet colorAt:'editFieldSelectionBackgroundColor' default:DefaultForegroundColor.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   549
    DefaultFont := StyleSheet fontAt:'editFieldFont' default:nil.
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   550
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   551
    "
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   552
     self updateStyleCache
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   553
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   554
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   555
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   556
!EditField methodsFor:'accessing-behavior'!
125
claus
parents: 122
diff changeset
   557
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   558
acceptOnLeave:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   559
    "set/clear the acceptOnLeave flag. The default is false.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   560
     If true, leaving the box (via return, cursor etc) accepts my 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   561
     string into the valueHolder (if any).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   562
     (actually, the set of keys can be specified with #leaveKeys:)"
125
claus
parents: 122
diff changeset
   563
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   564
     acceptOnLeave := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   565
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   566
    "Modified: 16.12.1995 / 16:26:45 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   567
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   568
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   569
acceptOnReturn:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   570
    "set/clear the acceptOnReturn flag. The default is false.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   571
     If true, leaving the box via return accepts my 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   572
     string into the valueHolder (if any)."
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   573
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   574
     acceptOnReturn := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   575
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   576
    "Modified: 16.12.1995 / 16:25:34 / cg"
125
claus
parents: 122
diff changeset
   577
!
claus
parents: 122
diff changeset
   578
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   579
crAction:aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   580
    "define an action to be evaluated when the return key is pressed."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   581
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   582
    crAction := aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   583
!
125
claus
parents: 122
diff changeset
   584
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   585
cursorMovementWhenUpdating:aSymbol
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   586
    "define what should be done with the cursor, when I update
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   587
     my contents from the model. Allowed arguments are:
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   588
        #keep / nil     -> stay where it was
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   589
        #endOfLine      -> position cursor after the string
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   590
        #beginOfLine    -> position cursor to the beginning
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   591
     The default is #endOfLine.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   592
     This may be useful for fields which get new values assigned from
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   593
     the program (i.e. not from the user)"
125
claus
parents: 122
diff changeset
   594
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   595
    cursorMovementWhenUpdating := aSymbol
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   596
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   597
    "Modified: 16.12.1995 / 16:27:55 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   598
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   599
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   600
disable
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   601
    "disable the field; hide the cursor and ignore input"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   602
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   603
    enabled ifTrue:[
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   604
        enabled := false.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   605
        self hideCursor
125
claus
parents: 122
diff changeset
   606
    ]
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   607
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   608
    "Modified: 16.12.1995 / 16:28:05 / cg"
125
claus
parents: 122
diff changeset
   609
!
claus
parents: 122
diff changeset
   610
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   611
enable
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   612
    "enable the field; show the cursor and allow input"
127
claus
parents: 125
diff changeset
   613
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   614
    enabled ifFalse:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   615
"/        enableAction notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   616
"/            enableAction value
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   617
"/        ].
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   618
        enabled := true.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   619
        super showCursor
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   620
    ]
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   621
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   622
    "Modified: 16.12.1995 / 16:28:09 / cg"
127
claus
parents: 125
diff changeset
   623
!
claus
parents: 125
diff changeset
   624
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   625
enableAction:aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   626
    "define an action to be evaluated when enabled by clicking upon"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   627
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   628
    enableAction := aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   629
!
125
claus
parents: 122
diff changeset
   630
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   631
entryCompletionBlock:aOneArgBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   632
    "define an action to be evaluated when Tab (NameCompletion) is pressed.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   633
     The block gets the current contents as argument."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   634
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   635
    entryCompletionBlock := aOneArgBlock
125
claus
parents: 122
diff changeset
   636
!
claus
parents: 122
diff changeset
   637
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   638
immediateAccept:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   639
    "set/clear the immediateAccept flag. The default is false.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   640
     If true, every pressed key immediately accepts my 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   641
     string into the valueHolder (if any)."
155
claus
parents: 144
diff changeset
   642
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   643
     immediateAccept := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   644
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   645
    "Modified: 16.12.1995 / 16:25:57 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   646
!
155
claus
parents: 144
diff changeset
   647
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   648
leaveAction:aBlock
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   649
    "define an action to be evaluated when field is left by return or cursor keys.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   650
     (actually, the set of keys can be specified with #leaveKeys:)"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   651
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   652
    leaveAction := aBlock
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   653
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   654
    "Modified: 16.12.1995 / 16:26:36 / cg"
155
claus
parents: 144
diff changeset
   655
!
claus
parents: 144
diff changeset
   656
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   657
leaveKeys:aCollectionOfKeySymbols 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   658
    "define the set of keys which are interpreted as leaveKeys.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   659
     I.e. those that make the field inactive and accept (if acceptOnLeave is true).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   660
     The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return."
155
claus
parents: 144
diff changeset
   661
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   662
    leaveKeys := aCollectionOfKeySymbols
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   663
!
155
claus
parents: 144
diff changeset
   664
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   665
tabAction:aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   666
    "define an action to be evaluated when the tabulator key is pressed."
155
claus
parents: 144
diff changeset
   667
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   668
    tabAction := aBlock
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   669
! !
125
claus
parents: 122
diff changeset
   670
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   671
!EditField methodsFor:'accessing-channels'!
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   672
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   673
enableChannel 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   674
    ^ enableChannel
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   675
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   676
    "Modified: 6.9.1995 / 13:43:33 / claus"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   677
    "Created: 16.12.1995 / 16:29:05 / cg"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   678
    "Modified: 16.12.1995 / 16:48:47 / cg"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   679
!
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   680
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   681
enableChannel:aValueHolder 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   682
    |wasEnabled|
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   683
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   684
    enableChannel notNil ifTrue:[
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   685
        wasEnabled := enableChannel value.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   686
        enableChannel retractInterestsFor:self. 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   687
    ] ifFalse:[
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   688
        wasEnabled := enabled
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   689
    ].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   690
    enableChannel := aValueHolder.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   691
    aValueHolder onChangeSend:#enableStateChange to:self.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   692
    enableChannel value ~~ wasEnabled ifTrue:[
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   693
        self enableStateChange
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   694
    ]
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   695
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   696
    "Created: 16.12.1995 / 16:35:32 / cg"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   697
! !
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   698
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   699
!EditField methodsFor:'accessing-contents'!
125
claus
parents: 122
diff changeset
   700
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   701
contents
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   702
    "return contents as a string
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   703
     - redefined since EditFields hold only one line of text.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   704
    In your application, please use #editValue; 
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   705
    it uses a converter (if any) and is compatible to ST-80."
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   706
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   707
    list isNil ifTrue:[^ ''].
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   708
    (list size == 0) ifTrue:[^ ''].
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   709
    ^ list at:1
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   710
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   711
125
claus
parents: 122
diff changeset
   712
contents:someText
claus
parents: 122
diff changeset
   713
    "set the contents from a string
claus
parents: 122
diff changeset
   714
     - redefined to place the cursor to the end.
claus
parents: 122
diff changeset
   715
    In your application, please use #editValue:; 
claus
parents: 122
diff changeset
   716
    it uses a converter (if any) and is compatible to ST-80."
claus
parents: 122
diff changeset
   717
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   718
    |newCol|
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   719
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   720
    newCol := cursorCol.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   721
125
claus
parents: 122
diff changeset
   722
    super contents:someText.
claus
parents: 122
diff changeset
   723
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   724
    cursorMovementWhenUpdating == #endOfLine ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   725
	 newCol := (someText size + 1).
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   726
    ] ifFalse:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   727
	cursorMovementWhenUpdating == #beginOfLine ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   728
	    newCol := 1
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   729
	] ifFalse:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   730
	    "/ default: stay where it was
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   731
	]
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   732
    ].
125
claus
parents: 122
diff changeset
   733
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   734
    self cursorCol:newCol.
125
claus
parents: 122
diff changeset
   735
!
claus
parents: 122
diff changeset
   736
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   737
converter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   738
    "return the converter (if any)."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   739
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   740
    ^ converter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   741
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   742
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   743
converter:aConverter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   744
    "set the converter. If non-nil,
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   745
     the converter is applied to the text to convert from the string
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   746
     representation to the actual object value and vice versa.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   747
     The default converter is nil, meaning no-conversion
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   748
     (i.e. the edited object is the string itself."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   749
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   750
    converter := aConverter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   751
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   752
125
claus
parents: 122
diff changeset
   753
editValue
claus
parents: 122
diff changeset
   754
    "if the field edits a string, this is a name alias for #contents.
claus
parents: 122
diff changeset
   755
     Otherwise, if there is a converter, return the edited string
claus
parents: 122
diff changeset
   756
     converted to an appropriate object."
claus
parents: 122
diff changeset
   757
claus
parents: 122
diff changeset
   758
    |string|
claus
parents: 122
diff changeset
   759
claus
parents: 122
diff changeset
   760
    string := self contents.
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
   761
    string isNil ifTrue:[string := ''].
125
claus
parents: 122
diff changeset
   762
    converter isNil ifTrue:[^ string].
claus
parents: 122
diff changeset
   763
    ^ converter readValueFrom:string 
claus
parents: 122
diff changeset
   764
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   765
125
claus
parents: 122
diff changeset
   766
editValue:aStringOrObject
claus
parents: 122
diff changeset
   767
    "set the contents. If there is a converter, use it to convert
claus
parents: 122
diff changeset
   768
     the object into a printed representation.
claus
parents: 122
diff changeset
   769
     Otherwise, the argument is supposed to be a string like object,
claus
parents: 122
diff changeset
   770
     and used directly (i.e. this is equivalent to sending #contents:)."
claus
parents: 122
diff changeset
   771
claus
parents: 122
diff changeset
   772
    self editValue:aStringOrObject selected:false
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   773
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   774
125
claus
parents: 122
diff changeset
   775
editValue:aStringOrObject selected:aBoolean
claus
parents: 122
diff changeset
   776
    "set the contents. If there is a converter, use it to convert
claus
parents: 122
diff changeset
   777
     the object into a printed representation.
claus
parents: 122
diff changeset
   778
     Otherwise, the argument is supposed to be a string like object,
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   779
     and used directly (i.e. this is equivalent to sending #initialText:selected:)."
125
claus
parents: 122
diff changeset
   780
claus
parents: 122
diff changeset
   781
    |string|
claus
parents: 122
diff changeset
   782
claus
parents: 122
diff changeset
   783
    converter notNil ifTrue:[
claus
parents: 122
diff changeset
   784
	string := converter printStringFor:aStringOrObject
claus
parents: 122
diff changeset
   785
    ] ifFalse:[
claus
parents: 122
diff changeset
   786
	string :=  aStringOrObject.
claus
parents: 122
diff changeset
   787
    ].
claus
parents: 122
diff changeset
   788
    self contents:string.
claus
parents: 122
diff changeset
   789
    aBoolean ifTrue:[
claus
parents: 122
diff changeset
   790
	self selectFromLine:1 col:1 toLine:1 col:string size
claus
parents: 122
diff changeset
   791
    ]
claus
parents: 122
diff changeset
   792
!
claus
parents: 122
diff changeset
   793
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   794
initialText:aString
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   795
    "set the initialText and select it"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   796
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   797
    self initialText:aString selected:true
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   798
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   799
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   800
initialText:aString selected:aBoolean
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   801
    "set the initialText and select it if aBoolean is true"
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   802
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   803
    |len s|
125
claus
parents: 122
diff changeset
   804
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   805
    leftOffset := 0.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   806
    (s := aString) notNil ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   807
	s := s asString
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   808
    ].
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   809
    self contents:s.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   810
    aBoolean ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   811
	(len := s size) ~~ 0 ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   812
	    self selectFromLine:1 col:1 toLine:1 col:len
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   813
	]
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   814
    ]
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   815
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   816
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   817
list:someText
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   818
    "low level access to the underlying contents' list.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   819
     Redefined to force text to 1 line, and notify dependents
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   820
     of any changed extent-wishes (for automatic box resizing)."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   821
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   822
    |l oldWidth|
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   823
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   824
    l := someText.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   825
    l size > 1 ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   826
	l := OrderedCollection with:(l at:1)
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   827
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   828
    oldWidth := self widthOfContents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   829
    super list:l.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   830
    self widthOfContents ~~ oldWidth ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   831
	self changed:#preferredExtent
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   832
    ]
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   833
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   834
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   835
stringValue
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   836
    "alias for #contents - for compatibility with ST-80's InputField"
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   837
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   838
    ^ self contents
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   839
! !
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   840
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   841
!EditField methodsFor:'accessing-look'!
125
claus
parents: 122
diff changeset
   842
155
claus
parents: 144
diff changeset
   843
maxChars
claus
parents: 144
diff changeset
   844
    "return the maximum number of characters that are allowed in
claus
parents: 144
diff changeset
   845
     the field. 
claus
parents: 144
diff changeset
   846
     A limit of nil means: unlimited. This is the default."
claus
parents: 144
diff changeset
   847
claus
parents: 144
diff changeset
   848
    ^ lengthLimit
claus
parents: 144
diff changeset
   849
claus
parents: 144
diff changeset
   850
    "Modified: 6.9.1995 / 13:43:33 / claus"
claus
parents: 144
diff changeset
   851
!
claus
parents: 144
diff changeset
   852
125
claus
parents: 122
diff changeset
   853
maxChars:aNumberOrNil
claus
parents: 122
diff changeset
   854
    "set the maximum number of characters that are allowed in
claus
parents: 122
diff changeset
   855
     the field. Additional input will be ignored by the field.
claus
parents: 122
diff changeset
   856
     A limit of nil means: unlimited. This is the default.
claus
parents: 122
diff changeset
   857
     This method has been renamed from #lengthLimit: for ST-80
claus
parents: 122
diff changeset
   858
     compatibility."
claus
parents: 122
diff changeset
   859
claus
parents: 122
diff changeset
   860
    lengthLimit := aNumberOrNil
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   861
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   862
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   863
passwordCharacter
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   864
    "return the passwordCharacter;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   865
     If nonNil, that one is replacing typed input
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   866
     (for secret input)"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   867
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   868
    ^ passwordCharacter
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   869
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   870
    "Modified: 6.9.1995 / 12:25:39 / claus"
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   871
    "Modified: 16.12.1995 / 16:24:25 / cg"
125
claus
parents: 122
diff changeset
   872
!
claus
parents: 122
diff changeset
   873
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   874
passwordCharacter:aCharacter
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   875
    "set the passwordCharacter;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   876
     If nonNil, that one is replacing typed input
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   877
     (for secret input)"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   878
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   879
    passwordCharacter := aCharacter
97
cbf495fe3b64 *** empty log message ***
claus
parents: 77
diff changeset
   880
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   881
    "Modified: 6.9.1995 / 12:25:33 / claus"
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   882
    "Modified: 16.12.1995 / 16:24:33 / cg"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
   883
! !
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
   884
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   885
!EditField methodsFor:'cursor drawing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   886
155
claus
parents: 144
diff changeset
   887
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
claus
parents: 144
diff changeset
   888
    startVisLineNr to:endVisLineNr do:[:visLine |
claus
parents: 144
diff changeset
   889
	self drawVisibleLine:visLine with:fg and:bg
claus
parents: 144
diff changeset
   890
    ]
claus
parents: 144
diff changeset
   891
claus
parents: 144
diff changeset
   892
    "Modified: 6.9.1995 / 12:24:29 / claus"
claus
parents: 144
diff changeset
   893
!
claus
parents: 144
diff changeset
   894
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   895
showCursor
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   896
    "make cursor visible if currently invisible - but only if this
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   897
     EditField is enabled"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   898
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   899
    enabled ifTrue:[super showCursor]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   900
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   901
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   902
!EditField methodsFor:'cursor movement'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   903
125
claus
parents: 122
diff changeset
   904
cursorCol:col
claus
parents: 122
diff changeset
   905
    "redefined to lock the cursor at the end, if I have a lngthLimit"
claus
parents: 122
diff changeset
   906
claus
parents: 122
diff changeset
   907
    |c sz|
claus
parents: 122
diff changeset
   908
claus
parents: 122
diff changeset
   909
    c := col.
claus
parents: 122
diff changeset
   910
    lengthLimit notNil ifTrue:[
claus
parents: 122
diff changeset
   911
	sz := lengthLimit.
claus
parents: 122
diff changeset
   912
	c > sz ifTrue:[
claus
parents: 122
diff changeset
   913
	    c := sz+1.
claus
parents: 122
diff changeset
   914
	]
claus
parents: 122
diff changeset
   915
    ].
claus
parents: 122
diff changeset
   916
    super cursorCol:c
claus
parents: 122
diff changeset
   917
!
claus
parents: 122
diff changeset
   918
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   919
cursorDown
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   920
    "catch cursor movement"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   921
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   922
    (cursorVisibleLine == nLinesShown) ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   923
	super cursorDown
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   924
    ]
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   925
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   926
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   927
cursorLine:line col:col
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   928
    "catch cursor movement"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   929
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   930
    super cursorLine:1 col:col
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   931
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   932
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   933
!EditField methodsFor:'editing'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   934
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   935
paste:someText
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   936
    "redefined to force text to 1 line"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   937
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   938
    super paste:someText.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   939
    list size > 1 ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   940
	self deleteFromLine:2 toLine:(list size)
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   941
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   942
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   943
70
14443a9ea4ec *** empty log message ***
claus
parents: 62
diff changeset
   944
!EditField methodsFor:'event handling'!
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
   945
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   946
buttonPress:button x:x y:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   947
    "enable myself on mouse click"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   948
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   949
    enabled ifFalse:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   950
	enabled := true.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   951
	super buttonPress:button x:x y:y.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   952
	enableAction notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   953
	    enableAction value
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   954
	]
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   955
    ] ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   956
	super buttonPress:button x:x y:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   957
    ]
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   958
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   959
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   960
canHandle:aKey
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   961
    "return true, if the receiver would like to handle aKey
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   962
     (usually from another view, when the receiver is part of
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   963
      a more complex dialog box).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   964
     We do return true here, since the editfield will handle
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   965
     all keys.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   966
     OBSOLETE: dont use this anymore - its a leftover for the tableWidget"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   967
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   968
    ^ true
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   969
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   970
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   971
enableStateChange
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   972
    enableChannel value ifTrue:[
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   973
        self enable
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   974
    ] ifFalse:[
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   975
        self disable
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   976
    ].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   977
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   978
    "Created: 16.12.1995 / 16:35:39 / cg"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   979
    "Modified: 16.12.1995 / 16:36:13 / cg"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   980
!
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   981
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   982
focusIn
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   983
    "got the explicit focus"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   984
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   985
    enabled ifFalse:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   986
	enabled := true.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   987
	super focusIn.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   988
	enableAction notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   989
	    enableAction value
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   990
	]
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   991
    ] ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   992
	super focusIn
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   993
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   994
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   995
125
claus
parents: 122
diff changeset
   996
keyPress:key x:x y:y
claus
parents: 122
diff changeset
   997
    "if keyHandler is defined, pass input; otherwise check for leave
claus
parents: 122
diff changeset
   998
     keys"
claus
parents: 122
diff changeset
   999
132
claus
parents: 131
diff changeset
  1000
    <resource: #keyboard (#DeleteLine #EndOfText)>
claus
parents: 131
diff changeset
  1001
163
claus
parents: 155
diff changeset
  1002
    |leave xCol newOffset oldWidth newWidth s|
125
claus
parents: 122
diff changeset
  1003
claus
parents: 122
diff changeset
  1004
    enabled ifFalse:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1005
        ^ self
125
claus
parents: 122
diff changeset
  1006
    ].
claus
parents: 122
diff changeset
  1007
claus
parents: 122
diff changeset
  1008
    (key == #DeleteLine) ifTrue:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1009
        Smalltalk at:#CopyBuffer put:(self contents).
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1010
        self contents:''. ^ self
125
claus
parents: 122
diff changeset
  1011
    ].
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1012
125
claus
parents: 122
diff changeset
  1013
    (key == #Tab) ifTrue:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1014
        tabAction notNil ifTrue:[tabAction value. ^ self].
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1015
        entryCompletionBlock notNil ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1016
            s := self contents.
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1017
            s isNil ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1018
                s := ''
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1019
            ] ifFalse:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1020
                s := s asString
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1021
            ].
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1022
            entryCompletionBlock value:s. ^ self
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1023
        ]
125
claus
parents: 122
diff changeset
  1024
    ].
claus
parents: 122
diff changeset
  1025
    (key == #Return) ifTrue:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1026
        crAction notNil ifTrue:[crAction value. ^ self].
125
claus
parents: 122
diff changeset
  1027
    ].
claus
parents: 122
diff changeset
  1028
    leave := leaveKeys includes:key.
claus
parents: 122
diff changeset
  1029
    leave ifTrue:[
121
claus
parents: 120
diff changeset
  1030
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1031
        ((key == #Return and:[acceptOnReturn])
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1032
        or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1033
            self accept.
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1034
        ].
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1035
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1036
        leaveAction notNil ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1037
            ^ leaveAction value:key
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1038
        ].
125
claus
parents: 122
diff changeset
  1039
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1040
        x >= 0 ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1041
            "
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1042
             let superview know about the leave ...
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1043
             This is a temporary kludge for the tableWidget -
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1044
             it is no clean coding style. Should make the tableWidget
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1045
             a proper model and handle it via the changed mechanism ....
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1046
            "
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1047
            (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1048
                superView keyPress:key x:x y:y.
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1049
            ].
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1050
        ].
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1051
        ^ self
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1052
    ].
121
claus
parents: 120
diff changeset
  1053
125
claus
parents: 122
diff changeset
  1054
    "
claus
parents: 122
diff changeset
  1055
     ignore some keys (if not a leaveKey) ...
claus
parents: 122
diff changeset
  1056
    "
claus
parents: 122
diff changeset
  1057
    (key == #Find) ifTrue:[^self].
claus
parents: 122
diff changeset
  1058
    (key == #FindNext) ifTrue:[^self].
claus
parents: 122
diff changeset
  1059
    (key == #FindPrev) ifTrue:[^self].
claus
parents: 122
diff changeset
  1060
    (key == #GotoLine) ifTrue:[^self].
claus
parents: 122
diff changeset
  1061
claus
parents: 122
diff changeset
  1062
    "
claus
parents: 122
diff changeset
  1063
     a normal key - let superclass's method insert it
claus
parents: 122
diff changeset
  1064
    "
claus
parents: 122
diff changeset
  1065
    oldWidth := self widthOfContents.
claus
parents: 122
diff changeset
  1066
    super keyPress:key x:x y:y.
claus
parents: 122
diff changeset
  1067
claus
parents: 122
diff changeset
  1068
    "
claus
parents: 122
diff changeset
  1069
     for end-of-text, also move to end-of-line
claus
parents: 122
diff changeset
  1070
    "
claus
parents: 122
diff changeset
  1071
    key == #EndOfText ifTrue:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1072
        super keyPress:#EndOfLine x:x y:y.
125
claus
parents: 122
diff changeset
  1073
    ].
claus
parents: 122
diff changeset
  1074
    newWidth := self widthOfContents.
claus
parents: 122
diff changeset
  1075
claus
parents: 122
diff changeset
  1076
    "
claus
parents: 122
diff changeset
  1077
     should (& can) we resize ?
claus
parents: 122
diff changeset
  1078
    "
claus
parents: 122
diff changeset
  1079
    xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
claus
parents: 122
diff changeset
  1080
    (xCol > (width * (5/6))) ifTrue:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1081
        self changed:#preferredExtent
125
claus
parents: 122
diff changeset
  1082
    ] ifFalse:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1083
        newWidth < (width * (1/6)) ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1084
            self changed:#preferredExtent
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1085
        ]
125
claus
parents: 122
diff changeset
  1086
    ].
claus
parents: 122
diff changeset
  1087
claus
parents: 122
diff changeset
  1088
    "
155
claus
parents: 144
diff changeset
  1089
     did someone react (i.e. has my extent changed) ?
125
claus
parents: 122
diff changeset
  1090
     (if not, we scroll horizontally)
claus
parents: 122
diff changeset
  1091
    "
claus
parents: 122
diff changeset
  1092
    xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
claus
parents: 122
diff changeset
  1093
    (xCol > (width * (5/6))) ifTrue:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1094
        newOffset := leftOffset + (width // 2).
125
claus
parents: 122
diff changeset
  1095
    ] ifFalse:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1096
        (xCol < (width * (1/6))) ifTrue:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1097
            newOffset := 0 max: leftOffset - (width // 2).
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1098
        ] ifFalse:[
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1099
            newOffset := leftOffset
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1100
        ]
125
claus
parents: 122
diff changeset
  1101
    ].
claus
parents: 122
diff changeset
  1102
    newOffset ~~ leftOffset ifTrue:[
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1103
        self scrollHorizontalTo:newOffset.
155
claus
parents: 144
diff changeset
  1104
"/        leftOffset := newOffset.
claus
parents: 144
diff changeset
  1105
"/        self clear.
claus
parents: 144
diff changeset
  1106
"/        self redraw
125
claus
parents: 122
diff changeset
  1107
    ]
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1108
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1109
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1110
!EditField methodsFor:'initialization'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1111
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1112
editMenu
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1113
    |labels selectors m|
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1114
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1115
    labels := #(
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1116
		'copy'
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1117
		'cut'
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1118
		'paste'
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1119
"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1120
		'replace'
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1121
"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1122
		'-'
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1123
		'accept'
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1124
	       ).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1125
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1126
     selectors := #(
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1127
		 copySelection
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1128
		 cut
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1129
		 paste
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1130
"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1131
		 replace
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1132
"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1133
		 nil
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1134
		 accept
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1135
		).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1136
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1137
    m := PopUpMenu 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1138
	  labels:(resources array:labels)
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1139
	  selectors:selectors.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1140
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1141
    self hasSelection ifFalse:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1142
	m disableAll:#(copySelection cut)
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1143
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1144
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1145
    ^ m
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1146
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1147
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1148
initStyle
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1149
    super initStyle.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1150
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1151
    DefaultBackgroundColor notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1152
	bgColor := DefaultBackgroundColor on:device.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1153
	self viewBackground:bgColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1154
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1155
    fgColor := DefaultForegroundColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1156
    selectionFgColor := DefaultSelectionForegroundColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1157
    selectionBgColor := DefaultSelectionBackgroundColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1158
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1159
    DefaultFont notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1160
	font := DefaultFont on:device
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1161
    ]
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1162
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1163
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1164
initialize
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1165
    super initialize.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1166
    self height:(font height + font descent + (topMargin * 2)).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1167
    enabled := true.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1168
    fixedSize := true.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1169
    nFullLinesShown := 1.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1170
    nLinesShown := 1.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1171
    immediateAccept := false.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1172
"/    acceptOnLeave := false.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1173
"/    acceptOnReturn := false.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1174
    acceptOnLeave := acceptOnReturn := true.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1175
    cursorShown := true.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1176
    leaveKeys := self class defaultLeaveKeys.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1177
    cursorMovementWhenUpdating := #endOfLine
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1178
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1179
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1180
!EditField methodsFor:'private'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1181
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1182
argForChangeMessage
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1183
    "redefined to send use converted value (if I have one)"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1184
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1185
    ^ self editValue
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1186
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1187
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1188
getListFromModel
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1189
    "redefined to aquire the text via the aspectMsg - not the listMsg,
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1190
     and to ignore updates resulting from my own change."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1191
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1192
    "
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1193
     ignore updates from my own change
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1194
    "
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1195
    lockUpdates ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1196
	lockUpdates := false.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1197
	^ self
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1198
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1199
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1200
    (model notNil and:[aspectMsg notNil]) ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1201
	self editValue:(model perform:aspectMsg).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1202
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1203
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1204
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1205
startAutoScrollDown:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1206
    "no vertical scrolling in editfields"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1207
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1208
    ^ self
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1209
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1210
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1211
startAutoScrollUp:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1212
    "no vertical scrolling in editfields"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1213
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1214
    ^ self
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1215
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1216
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1217
textChanged
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1218
    "this is sent by mySelf (somewhere in a superclass) whenever
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1219
     my contents has changed. 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1220
     A good place to add immediateAccept functionality and check for the
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1221
     lengthLimit."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1222
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1223
    |string c|
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1224
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1225
    super textChanged.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1226
    string := self contents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1227
    lengthLimit notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1228
	string size > lengthLimit ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1229
	    c := cursorCol.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1230
	    self contents:(string copyTo:lengthLimit).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1231
	    self flash.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1232
	    self cursorCol:c.
125
claus
parents: 122
diff changeset
  1233
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1234
    ].
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1235
    immediateAccept ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1236
	self accept
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1237
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1238
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1239
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1240
visibleAt:visLineNr
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1241
    "return the string at lineNr for display.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1242
     If there is a password character, return a string consisting of those only."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1243
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1244
    |s|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1245
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1246
    s := super visibleAt:visLineNr.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1247
    passwordCharacter notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1248
	^ String new:(s size) withAll:passwordCharacter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1249
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1250
    ^ s
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1251
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1252
    "Modified: 6.9.1995 / 12:25:06 / claus"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1253
! !
125
claus
parents: 122
diff changeset
  1254
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1255
!EditField methodsFor:'queries'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1256
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1257
preferredExtent
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1258
    "return the preferred extent of this view.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1259
     That is the width of the string plus some extra, 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1260
     but not wider than half of the screen"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1261
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1262
    |string w f|
125
claus
parents: 122
diff changeset
  1263
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1264
    string := self contents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1265
    (string isNil or:[string isBlank]) ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1266
	string := '          ' "/ just any string is ok ^ super preferredExtent
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1267
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1268
    f := font on:device.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1269
    w := ((f widthOf:string) * 1.5) rounded.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1270
    w := w min:(device width // 2).
231
014756a636e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1271
"/    ^ w @ (f height * 1.5) rounded
014756a636e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1272
    ^ w @ (f height + f descent + (margin * 2)"* 1.5") rounded
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1273
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1274
    "Modified: 6.9.1995 / 19:24:06 / claus"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1275
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1276
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1277
specClass
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1278
    self class == EditField ifTrue:[^ InputFieldSpec].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1279
    ^ nil
125
claus
parents: 122
diff changeset
  1280
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1281
    "Modified: 5.9.1995 / 17:28:27 / claus"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1282
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1283
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1284
!EditField methodsFor:'realization'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1285
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1286
realize
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1287
    "scroll back to beginning when realized"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1288
    leftOffset := 0.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1289
    super realize
125
claus
parents: 122
diff changeset
  1290
! !
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1291
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1292
!EditField methodsFor:'scrolling'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1293
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1294
makeColVisible:col inLine:line
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1295
    "dont scroll for the cursor, if its behond the text and a lengthLimit
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1296
     is present."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1297
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1298
    lengthLimit notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1299
	(col == cursorCol and:[col > lengthLimit]) ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1300
	    ^ super makeColVisible:lengthLimit inLine:line
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1301
	]
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1302
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1303
    ^ super makeColVisible:col inLine:line
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1304
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1305
    "Modified: 6.9.1995 / 13:57:53 / claus"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1306
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1307
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1308
!EditField methodsFor:'selections'!
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1309
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1310
validateNewSelection
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1311
     "make certain that only one line is ever selected"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1312
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1313
     selectionEndLine > 1 ifTrue:[
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1314
	selectionEndLine := 2. selectionEndCol := 0
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1315
     ].
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1316
! !
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1317
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1318
!EditField class methodsFor:'documentation'!
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1319
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1320
version
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1321
    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.37 1996-01-10 14:48:41 ca Exp $'
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1322
! !