EditField.st
changeset 290 f539121393b1
parent 279 b9fa9180aca4
child 298 932fa5ca44f8
equal deleted inserted replaced
289:82d20a3e2fe8 290:f539121393b1
    12 
    12 
    13 EditTextView subclass:#EditField
    13 EditTextView subclass:#EditField
    14 	instanceVariableNames:'leaveAction enabled enableAction crAction tabAction converter
    14 	instanceVariableNames:'leaveAction enabled enableAction crAction tabAction converter
    15 		leaveKeys immediateAccept acceptOnLeave acceptOnReturn
    15 		leaveKeys immediateAccept acceptOnLeave acceptOnReturn
    16 		lengthLimit entryCompletionBlock passwordCharacter
    16 		lengthLimit entryCompletionBlock passwordCharacter
    17 		cursorMovementWhenUpdating enableChannel'
    17 		cursorMovementWhenUpdating enableChannel autoScrollHorizontally'
    18 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    18 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    19 		DefaultSelectionForegroundColor DefaultSelectionBackgroundColor
    19 		DefaultSelectionForegroundColor DefaultSelectionBackgroundColor
    20 		DefaultFont'
    20 		DefaultFont'
    21 	poolDictionaries:''
    21 	poolDictionaries:''
    22 	category:'Views-Text'
    22 	category:'Views-Text'
    42 "
    42 "
    43     an editable text-field. Realized by using an EditTextView,
    43     an editable text-field. Realized by using an EditTextView,
    44     and forcing its size to 1 line - disabling cursor movement
    44     and forcing its size to 1 line - disabling cursor movement
    45     in the vertical direction.
    45     in the vertical direction.
    46 
    46 
       
    47     Basically, an editField is an editor for a single line text,
       
    48     and provides the usual access protocol as defined in its superClasses
       
    49     (especially: #contents / #contents:).
       
    50 
       
    51     The above underlying internal mechanism can be used for fields which
       
    52     are passive; i.e. into which text can be entered and the value (string)
       
    53     is extracted actively by someone else.
       
    54 
       
    55   accepting:
       
    56     The opposite way to use editFields is to connect them to a model
       
    57     and let the field notify changes to it.
       
    58     This notification is called ``accepting''.
       
    59     Unless accepted, the models value is not updated from the editFields contents
       
    60     this default is the normal operation and way things should work, since most
       
    61     uses of editFields are not interrested in every individual change
       
    62     (i.e. getting each keyStroke when a long number is entered).
       
    63     The default behavior is to ``accept'' when either return or a cursorUp/Down
       
    64     key is pressed in a field.
       
    65     However, the field can setup to accept/not accept on leave, on return
       
    66     or on each individual key input.
       
    67     See the methods #acceptOnLeave: / #acceptOnReturn: / #immediateAccept.
       
    68 
       
    69     In addition, the set of keys which are considered ``leaveKeys'' can be
       
    70     specified by #leaveKeys: (in case you need keys other than Return, CursorUp/Down).
       
    71 
       
    72   models value vs. field contents:
       
    73     Although the field internally keeps its contents as some string object,
       
    74     the application may prefer to think of numbers, floats, yes/no values etc.
       
    75     To support this, a converter may defined, which is responsible for conversion of
       
    76     strings to/from the models domain value.
       
    77     If present (i.e. nonNil), the converter is asked to convert a string to the models
       
    78     domain with #readValueFrom:aString and vice versa, a value to a string by #printStringFor:.
       
    79     The PrintConverter class already provides a number of standard conversions, see the examples.
       
    80     To access a converted value directly (i.e. not via the model), use #editValue.
       
    81 
       
    82   grouping:
       
    83     Individual fields do not know about being included in a group. This must be arranged on the
       
    84     outside, by placing multiple fields into an EnterFieldGroup.
       
    85     This groupObject keeps a reference to one active field, and forwards input from any other
       
    86     field to the active one. Also have a look at the examples for this.
       
    87 
       
    88   input completion:
       
    89     To support input completion (i.e. filename completion, classname completion etc.),
       
    90     a completionBlock can be defined which (if non-nil) is evaluated when the completion-key
       
    91     is pressed and its value is taken as the new field-contents. 
       
    92     The physical completion-key is the Tab key (this one cannot be defined by
       
    93     the keyboardTranslation mechanism, since that would disable the Tab-key on regular text views.
       
    94 
       
    95 
       
    96 
    47     Instance variables:
    97     Instance variables:
    48 
    98 
    49       leaveAction    <Block | nil>              if non-nil, this is evaluated with
    99       leaveAction    <Block | nil>              if non-nil, this is evaluated with
    50 						the key (#Return, #CursorUp etc.) when
   100 						the key (#Return, #CursorUp etc.) when
    51 						the field is left via keyboard keys.
   101 						the field is left via keyboard keys.
    64 						(however, this block can perform additional checks and send
   114 						(however, this block can perform additional checks and send
    65 						 a #accept then)
   115 						 a #accept then)
    66 
   116 
    67       tabAction      <Block | nil>              if non-nil, keyboard input of a tab character
   117       tabAction      <Block | nil>              if non-nil, keyboard input of a tab character
    68 						is not entered into the text, instead this block
   118 						is not entered into the text, instead this block
    69 						is evaluated.
   119 						is evaluated. Also, no input completion is performed if
       
   120 						tabAction is nonNil.
    70 
   121 
    71       converter      <PrintConverter | nil>     if non-nil, this is supposed to convert between
   122       converter      <PrintConverter | nil>     if non-nil, this is supposed to convert between
    72 						the object and its printed representation.
   123 						the object and its printed representation and vice versa.
    73 						Defaults to nil i.e. assume that strings are edited.
   124 						Defaults to nil i.e. assume that strings are edited.
    74 
   125 
    75       leaveKeys      <Collection>               keys which are interpreted as 'leving the field'
   126       leaveKeys      <Collection>               keys which are interpreted as 'leaving the field'
    76 
   127 
    77       immediateAccept   <Boolean>               if true, every change of the text is immediately
   128       immediateAccept   <Boolean>               if true, every change of the text is immediately
    78 						forwarded to the model/acceptBlock. If false,
   129 						forwarded to the model/acceptBlock. If false,
    79 						the changed value is only stored in the model
   130 						the changed value is only stored in the model
    80 						if the field is left or accepted.
   131 						if the field is left or accepted.
    93 examples 
   144 examples 
    94 "
   145 "
    95     see more examples in EnterFieldGroup>>examples.
   146     see more examples in EnterFieldGroup>>examples.
    96 
   147 
    97 
   148 
    98     basic field in a view:
   149     Step-by-step introduction:
    99 
   150 
   100         |top field|
   151 
   101 
   152     basic field in some view:
   102         top := StandardSystemView new.
   153 
   103         top extent:200@100.
   154 	|top field|
   104 
   155 
   105         field := EditField origin:0.0@0.0 in:top.
   156 	top := StandardSystemView new.
   106         field width:1.0.        'let its height as-is'.
   157 	top extent:200@100.
   107 
   158 
   108         top open
   159 	field := EditField origin:0.0@0.0 in:top.
       
   160 	field width:1.0.                                'let its height as-is'.
       
   161 
       
   162 	top open
   109 
   163 
   110 
   164 
   111     forward input in topView to the field:
   165     forward input in topView to the field:
   112     (currently, the field does not know this - therefore,
   166     (currently, the field does not know this - therefore,
   113      its been told here ... this may change)
   167      its been told here ... this may change)
   114 
   168 
   115         |top field|
   169 	|top field|
   116 
   170 
   117         top := StandardSystemView new.
   171 	top := StandardSystemView new.
   118         top extent:200@100.
   172 	top extent:200@100.
   119 
   173 
   120         field := EditField origin:0.0@0.0 in:top.
   174 	field := EditField origin:0.0@0.0 in:top.
   121         field width:1.0.        'let its height as-is'.
   175 	field width:1.0.                                'let its height as-is'.
   122 
   176 
   123         top delegate:(KeyboardForwarder toView:field).
   177 	top delegate:(KeyboardForwarder toView:field).
   124         field hasKeyboardFocus:true.
   178 	field hasKeyboardFocus:true.
   125         top open
   179 	top open
   126 
   180 
   127 
   181 
   128     to make it look better: set some inset:
   182     to make it look better: set some inset:
   129 
   183 
   130         |top field|
   184 	|top field spacing|
   131 
   185 
   132         top := StandardSystemView new.
   186 	top := StandardSystemView new.
   133         top extent:200@100.
   187 	top extent:200@100.
   134 
   188 
   135         field := EditField origin:0.0@ViewSpacing in:top.
   189 	spacing := View viewSpacing.
   136         field width:1.0.        'let its height as-is'.
   190 	field := EditField origin:(0.0 @ spacing) in:top.
   137         field leftInset:ViewSpacing;
   191 	field width:1.0.                                        'let its height as-is'.
   138               rightInset:ViewSpacing.
   192 	field leftInset:spacing; rightInset:spacing.
   139 
   193 
   140         top open
   194 	top open
   141 
   195 
   142 
   196 
   143     give it an initial contents:
   197     give it an initial contents:
   144 
   198 
   145         |top field|
   199 	|top field|
   146 
   200 
   147         top := StandardSystemView new.
   201 	top := StandardSystemView new.
   148         top extent:200@100.
   202 	top extent:200@100.
   149 
   203 
   150         field := EditField origin:0.0@ViewSpacing in:top.
   204 	field := EditField origin:(0.0 @ 0@0) in:top.
   151         field width:1.0.       
   205 	field width:1.0.       
   152         field leftInset:ViewSpacing;
   206 
   153               rightInset:ViewSpacing.
   207 	field editValue:'hello world'.
   154         field editValue:'hello world'.
   208 
   155 
   209 	top open
   156         top open
       
   157 
   210 
   158 
   211 
   159     have it preselected:
   212     have it preselected:
   160 
   213 
   161         |top field|
   214 	|top field|
   162 
   215 
   163         top := StandardSystemView new.
   216 	top := StandardSystemView new.
   164         top extent:200@100.
   217 	top extent:200@100.
   165 
   218 
   166         field := EditField origin:0.0@ViewSpacing in:top.
   219 	field := EditField origin:(0.0 @ 0.0) in:top.
   167         field width:1.0.     
   220 	field width:1.0.     
   168         field leftInset:ViewSpacing;
   221 	field editValue:'hello world' selected:true.
   169               rightInset:ViewSpacing.
   222 
   170         field editValue:'hello world' selected:true.
   223 	top open
   171 
       
   172         top open
       
   173 
   224 
   174 
   225 
   175     have part of it preselected:
   226     have part of it preselected:
   176 
   227 
   177         |top field|
   228 	|top field|
   178 
   229 
   179         top := StandardSystemView new.
   230 	top := StandardSystemView new.
   180         top extent:200@100.
   231 	top extent:200@100.
   181 
   232 
   182         field := EditField origin:0.0@ViewSpacing in:top.
   233 	field := EditField origin:(0.0 @ 0.0) in:top.
   183         field width:1.0.     
   234 	field width:1.0.     
   184         field leftInset:ViewSpacing;
   235 
   185               rightInset:ViewSpacing.
   236 	field editValue:'hello world'.
   186         field editValue:'hello world';
   237 	field selectFromCharacterPosition:1 to:5.
   187               selectFromCharacterPosition:1 to:5.
   238 
   188 
   239 	top open
   189         top open
       
   190 
   240 
   191 
   241 
   192     set a size limit:
   242     set a size limit:
   193 
   243 
   194         |top field|
   244 	|top field|
   195 
   245 
   196         top := StandardSystemView new.
   246 	top := StandardSystemView new.
   197         top extent:200@100.
   247 	top extent:200@100.
   198 
   248 
   199         field := EditField origin:0.0@ViewSpacing in:top.
   249 	field := EditField origin:(0.0 @ 0.0) in:top.
   200         field width:1.0.     
   250 	field width:1.0.     
   201         field leftInset:ViewSpacing;
   251 	field editValue:'hello'.
   202               rightInset:ViewSpacing.
   252 
   203         field editValue:'hello';
   253 	field maxChars:8.
   204               maxChars:8.
   254 
   205 
   255 	top open
   206         top open
   256 
       
   257 
       
   258     set a size limit, initial width and stop it from scrolling
       
   259     notice: you may prefer a constant-pitch font (such as courier):
       
   260 
       
   261 	|top field|
       
   262 
       
   263 	top := StandardSystemView new.
       
   264 	top extent:200@100.
       
   265 
       
   266 	field := EditField origin:(0.0 @ 0.0) in:top.
       
   267 	field innerWidth:(field font widthOf:'00000000').     
       
   268 	field editValue:'12345678'.
       
   269 
       
   270 	field maxChars:8.
       
   271 	field autoScroll:false.
       
   272 
       
   273 	top open
   207 
   274 
   208 
   275 
   209     enable / disable:
   276     enable / disable:
   210 
   277 
   211         |top panel check field ena|
   278 	|top panel check field ena|
   212 
   279 
   213         top := StandardSystemView new.
   280 	top := StandardSystemView new.
   214         top extent:200@100.
   281 	top extent:200@100.
   215 
   282 
   216         panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
   283 	panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
   217         panel horizontalLayout:#leftSpace.
   284 	panel horizontalLayout:#leftSpace.
   218 
   285 
   219         check := CheckBox label:'enable' in:panel.
   286 	check := CheckBox label:'enable' in:panel.
   220         check turnOn.
   287 	check turnOn.
   221         check action:[:onOff | onOff ifTrue:[field enable] ifFalse:[field disable]].
   288 	check action:[:onOff | onOff ifTrue:[field enable] ifFalse:[field disable]].
   222 
   289 
   223         panel add:(View new height:30).
   290 	panel add:(View new height:30).
   224 
   291 
   225         field := EditField in:panel.
   292 	field := EditField in:panel.
   226         field width:1.0.     
   293 	field width:1.0.     
   227         field leftInset:ViewSpacing;
   294 	field editValue:'hello'.
   228               rightInset:ViewSpacing.
       
   229         field editValue:'hello'.
       
   230         
   295         
   231         top open
   296 	top open
   232 
   297 
   233 
   298 
   234     enable / disable using a channel:
   299     enable / disable using a channel:
   235 
   300 
   236         |top panel check field ena|
   301 	|top panel check field ena|
   237 
   302 
   238         top := StandardSystemView new.
   303 	top := StandardSystemView new.
   239         top extent:200@100.
   304 	top extent:200@100.
   240 
   305 
   241         panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
   306 	panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
   242         panel horizontalLayout:#leftSpace.
   307 	panel horizontalLayout:#leftSpace.
   243 
   308 
   244         ena := true asValue.
   309 	ena := true asValue.
   245 
   310 
   246         check := CheckBox label:'enable' in:panel.
   311 	check := CheckBox label:'enable' in:panel.
   247         check model:ena.
   312 	check model:ena.
   248 
   313 
   249         panel add:(View new height:30).
   314 	panel add:(View new height:30).
   250 
   315 
   251         field := EditField in:panel.
   316 	field := EditField in:panel.
   252         field enableChannel:ena.
   317 	field enableChannel:ena.
   253         field width:1.0.     
   318 	field width:1.0.     
   254         field leftInset:ViewSpacing;
   319 	field editValue:'hello'.
   255               rightInset:ViewSpacing.
   320 
   256         field editValue:'hello'.
   321 	top open
   257 
       
   258         top open
       
   259 
   322 
   260 
   323 
   261     use a converter:
   324     use a converter:
   262       - numbers (default to 0):
   325       - numbers (default to 0):
   263 
   326 
   264         |top field|
   327 	|top field|
   265 
   328 
   266         top := StandardSystemView new.
   329 	top := StandardSystemView new.
   267         top extent:200@100.
   330 	top extent:200@100.
   268 
   331 
   269         field := EditField origin:0.0@ViewSpacing in:top.
   332 	field := EditField origin:0.0@ViewSpacing in:top.
   270         field width:1.0.
   333 	field width:1.0.
   271         field leftInset:ViewSpacing;
   334 	field leftInset:ViewSpacing;
   272               rightInset:ViewSpacing.
   335 	      rightInset:ViewSpacing.
   273 
   336 
   274         field converter:(PrintConverter new initForNumber).
   337 	field converter:(PrintConverter new initForNumber).
   275         field editValue:1234.
   338 	field editValue:1234.
   276         field acceptAction:[:value | Transcript showCr:value].
   339 	field acceptAction:[:value | Transcript showCr:value].
   277         field crAction:[field accept. top destroy].
   340 	field crAction:[field accept. top destroy].
   278         top open.
   341 	top open.
   279 
   342 
   280       - dates:
   343       - dates:
   281 
   344 
   282         |top field|
   345 	|top field|
   283 
   346 
   284         top := StandardSystemView new.
   347 	top := StandardSystemView new.
   285         top extent:200@100.
   348 	top extent:200@100.
   286 
   349 
   287         field := EditField origin:0.0@ViewSpacing in:top.
   350 	field := EditField origin:0.0@ViewSpacing in:top.
   288         field width:1.0.
   351 	field width:1.0.
   289         field leftInset:ViewSpacing;
   352 	field leftInset:ViewSpacing;
   290               rightInset:ViewSpacing.
   353 	      rightInset:ViewSpacing.
   291 
   354 
   292         field converter:(PrintConverter new initForDate).
   355 	field converter:(PrintConverter new initForDate).
   293         field editValue:Date today.
   356 	field editValue:Date today.
   294         field acceptAction:[:value | Transcript showCr:value class name , ' ' , value printString].
   357 	field acceptAction:[:value | Transcript showCr:value class name , ' ' , value printString].
   295         field crAction:[field accept. top destroy].
   358 	field crAction:[field accept. top destroy].
   296         top open.
   359 	top open.
   297 
   360 
   298 
   361 
   299     setting immediateAccept, makes the field update with every key:
   362     setting immediateAccept, makes the field update with every key:
   300 
   363 
   301       - immediate accept numbers, defaulting to nil:
   364       - immediate accept numbers, defaulting to nil:
   302 
   365 
   303         |top field|
   366 	|top field|
   304 
   367 
   305         top := StandardSystemView new.
   368 	top := StandardSystemView new.
   306         top extent:200@100.
   369 	top extent:200@100.
   307 
   370 
   308         field := EditField origin:0.0@ViewSpacing in:top.
   371 	field := EditField origin:0.0@ViewSpacing in:top.
   309         field width:1.0.
   372 	field width:1.0.
   310         field leftInset:ViewSpacing;
   373 	field leftInset:ViewSpacing;
   311               rightInset:ViewSpacing.
   374 	      rightInset:ViewSpacing.
   312 
   375 
   313         field converter:(PrintConverter new initForNumberOrNil).
   376 	field converter:(PrintConverter new initForNumberOrNil).
   314         field immediateAccept:true.
   377 	field immediateAccept:true.
   315         field editValue:1234.
   378 	field editValue:1234.
   316         field acceptAction:[:value | Transcript showCr:value].
   379 	field acceptAction:[:value | Transcript showCr:value].
   317         field crAction:[field accept. top destroy].
   380 	field crAction:[field accept. top destroy].
   318         top open.
   381 	top open.
   319 
   382 
   320 
   383 
       
   384 
       
   385     grouping multiple fields, and forward keyPres from the outer view to the active field
       
   386     (i.e. actually: to the group):
       
   387 
       
   388 	|top field1 field2 field3 group|
       
   389 
       
   390 
       
   391 	top := StandardSystemView new.
       
   392 	top extent:200@100.
       
   393 
       
   394 	field1 := EditField origin:(0.0 @ 0.0) in:top.
       
   395 	field1 width:1.0.
       
   396 
       
   397 	field2 := EditField origin:(0.0 @ 0.0) in:top.
       
   398 	field2 width:0.5.
       
   399 	field2 topInset:(field1 height); bottomInset:(field1 height negated).
       
   400 
       
   401 	field3 := EditField origin:(0.5 @ 0.0) in:top.
       
   402 	field3 width:0.5.
       
   403 	field3 topInset:(field1 height); bottomInset:(field1 height negated).
       
   404 
       
   405 	group := EnterFieldGroup new.
       
   406 	group add:field1; add:field2; add:field3.
       
   407 
       
   408 	top delegate:(KeyboardForwarder to:group).
       
   409 
       
   410 	top open.
       
   411 
       
   412         
       
   413     in addition: tell the group to close when the last field is left:
       
   414 
       
   415 	|top field1 field2 field3 group|
       
   416 
       
   417 
       
   418 	top := StandardSystemView new.
       
   419 	top extent:200@100.
       
   420 
       
   421 	field1 := EditField origin:(0.0 @ 0.0) in:top.
       
   422 	field1 width:1.0.
       
   423 
       
   424 	field2 := EditField origin:(0.0 @ 0.0) in:top.
       
   425 	field2 width:0.5.
       
   426 	field2 topInset:(field1 height); bottomInset:(field1 height negated).
       
   427 
       
   428 	field3 := EditField origin:(0.5 @ 0.0) in:top.
       
   429 	field3 width:0.5.
       
   430 	field3 topInset:(field1 height); bottomInset:(field1 height negated).
       
   431 
       
   432 	group := EnterFieldGroup new.
       
   433 	group add:field1; add:field2; add:field3.
       
   434 	group leaveAction:[top destroy].
       
   435 
       
   436 	top delegate:(KeyboardForwarder to:group).
       
   437 
       
   438 	top open.
   321 
   439 
   322 
   440 
   323     use a model:
   441     use a model:
   324     (see changing model value in inspector when return is pressed in the field)
   442     (see changing model value in inspector when return is pressed in the field)
   325 
   443 
   326         |top field model|
   444 	|top field model|
   327 
   445 
   328         model := 'hello world' asValue.
   446 	model := 'hello world' asValue.
   329 
   447 
   330         top := StandardSystemView new.
   448 	top := StandardSystemView new.
   331         top extent:200@100.
   449 	top extent:200@100.
   332 
   450 
   333         field := EditField origin:0.0@ViewSpacing in:top.
   451 	field := EditField origin:(0.0 @ 0.0) in:top.
   334         field width:1.0.
   452 	field width:1.0.
   335         field leftInset:ViewSpacing;
   453 	field model:model.
   336               rightInset:ViewSpacing.
   454 	field acceptOnReturn:true.
   337         field model:model.
   455 
   338         field acceptOnReturn:true.
   456 	top open.
   339 
   457 	model inspect.
   340         top open.
       
   341         model inspect.
       
   342 
   458 
   343 
   459 
   344     two views on the same model (each accepts on return):
   460     two views on the same model (each accepts on return):
   345 
   461 
   346         |top1 top2 field1 field2 model|
   462 	|top1 top2 field1 field2 model|
   347 
   463 
   348         model := 'hello world' asValue.
   464 	model := 'hello world' asValue.
   349 
   465 
   350         top1 := StandardSystemView new.
   466 	top1 := StandardSystemView new.
   351         top1 extent:200@100.
   467 	top1 extent:200@100.
   352         field1 := EditField origin:0.0@ViewSpacing in:top1.
   468 	field1 := EditField origin:(0.0 @ 0.0) in:top1.
   353         field1 width:1.0.
   469 	field1 width:1.0.
   354         field1 leftInset:ViewSpacing;
   470 	field1 model:model.
   355               rightInset:ViewSpacing.
   471 	field1 acceptOnReturn:true.
   356         field1 model:model.
   472 	top1 open.
   357         field1 acceptOnReturn:true.
   473 
   358         top1 open.
   474 	top2 := StandardSystemView new.
   359 
   475 	top2 extent:200@100.
   360         top2 := StandardSystemView new.
   476 	field2 := EditField origin:(0.0 @ 0.0) in:top2.
   361         top2 extent:200@100.
   477 	field2 width:1.0.
   362         field2 := EditField origin:0.0@ViewSpacing in:top2.
   478 	field2 model:model.
   363         field2 width:1.0.
   479 	field2 acceptOnReturn:true.
   364         field2 leftInset:ViewSpacing;
   480 	top2 open.
   365               rightInset:ViewSpacing.
       
   366         field2 model:model.
       
   367         field2 acceptOnReturn:true.
       
   368         top2 open.
       
   369 
   481 
   370     two views on the same model (no accept on return):
   482     two views on the same model (no accept on return):
   371 
   483 
   372         |top1 top2 field1 field2 model|
   484 	|top1 top2 field1 field2 model|
   373 
   485 
   374         model := 'hello world' asValue.
   486 	model := 'hello world' asValue.
   375 
   487 
   376         top1 := StandardSystemView new.
   488 	top1 := StandardSystemView new.
   377         top1 extent:200@100.
   489 	top1 extent:200@100.
   378         field1 := EditField origin:0.0@ViewSpacing in:top1.
   490 	field1 := EditField origin:(0.0 @ 0.0) in:top1.
   379         field1 width:1.0.
   491 	field1 width:1.0.
   380         field1 leftInset:ViewSpacing;
   492 	field1 model:model; acceptOnReturn:false.
   381               rightInset:ViewSpacing.
   493 	top1 open.
   382         field1 model:model; acceptOnReturn:false.
   494 
   383         top1 open.
   495 	top2 := StandardSystemView new.
   384 
   496 	top2 extent:200@100.
   385         top2 := StandardSystemView new.
   497 	field2 := EditField origin:(0.0 @ 0.0) in:top2.
   386         top2 extent:200@100.
   498 	field2 width:1.0.
   387         field2 := EditField origin:0.0@ViewSpacing in:top2.
   499 	field2 model:model; acceptOnReturn:false.
   388         field2 width:1.0.
   500 	top2 open.
   389         field2 leftInset:ViewSpacing;
   501 
   390               rightInset:ViewSpacing.
   502     with immediate accept (every key updates the model):
   391         field2 model:model; acceptOnReturn:false.
   503 
   392         top2 open.
   504 	|top1 top2 field1 field2 model|
   393 
   505 
   394     with immediate accept:
   506 	model := 'hello world' asValue.
   395 
   507 
   396         |top1 top2 field1 field2 model|
   508 	top1 := StandardSystemView new.
   397 
   509 	top1 extent:200@100.
   398         model := 'hello world' asValue.
   510 	field1 := EditField origin:(0.0 @ 0.0) in:top1.
   399 
   511 	field1 width:1.0.
   400         top1 := StandardSystemView new.
   512 	field1 model:model; immediateAccept:true.
   401         top1 extent:200@100.
   513 	top1 open.
   402         field1 := EditField origin:0.0@ViewSpacing in:top1.
   514 
   403         field1 width:1.0.
   515 	top2 := StandardSystemView new.
   404         field1 leftInset:ViewSpacing; rightInset:ViewSpacing.
   516 	top2 extent:200@100.
   405         field1 model:model; immediateAccept:true.
   517 	field2 := EditField origin:(0.0 @ 0.0) in:top2.
   406         top1 open.
   518 	field2 width:1.0.
   407 
   519 	field2 model:model; immediateAccept:true.
   408         top2 := StandardSystemView new.
   520 	top2 open.
   409         top2 extent:200@100.
       
   410         field2 := EditField origin:0.0@ViewSpacing in:top2.
       
   411         field2 width:1.0.
       
   412         field2 leftInset:ViewSpacing; rightInset:ViewSpacing.
       
   413         field2 model:model; immediateAccept:true.
       
   414         top2 open.
       
   415 
   521 
   416     just an example; a checkBox and an editField on the same model:
   522     just an example; a checkBox and an editField on the same model:
   417 
   523 
   418         |top1 top2 field1 box model|
   524 	|top1 top2 field1 box model|
   419 
   525 
   420         model := false asValue.
   526 	model := false asValue.
   421 
   527 
   422         top1 := StandardSystemView new.
   528 	top1 := StandardSystemView new.
   423         top1 extent:200@100.
   529 	top1 extent:200@100.
   424         field1 := EditField origin:0.0@ViewSpacing in:top1.
   530 	field1 := EditField origin:(0.0 @ 0.0) in:top1.
   425         field1 width:1.0.
   531 	field1 width:1.0.
   426         field1 leftInset:ViewSpacing;
   532 	field1 converter:(PrintConverter new initForYesNo).
   427               rightInset:ViewSpacing.
   533 	field1 model:model.
   428         field1 converter:(PrintConverter new initForYesNo).
   534 	top1 open.
   429         field1 model:model.
   535 
   430         top1 open.
   536 	top2 := StandardSystemView new.
   431 
   537 	top2 extent:200@100.
   432         top2 := StandardSystemView new.
   538 	box := CheckBox on:model.
   433         top2 extent:200@100.
   539 	box label:'on/off'.
   434         box := CheckBox on:model.
   540 	top2 add:box.
   435         box label:'on/off'.
   541 	top2 open.
   436         top2 add:box.
   542 
   437         top2 open.
   543 	model inspect.
   438 
       
   439         model inspect.
       
   440 
   544 
   441 
   545 
   442     connecting fields:
   546     connecting fields:
   443     update field2 wehenever field1 is changed.
   547     update field2 wehenever field1 is changed.
   444     (normally, the processing below (xChanged) is done in your application
   548     (normally, the processing below (xChanged) is done in your application
   445      class, or in a complex model. For the demonstration below, we use
   549      class, or in a complex model. For the demonstration below, we use
   446      a Plug to simulate the protocol.)
   550      a Plug to simulate the protocol.)
   447 
   551 
   448         |application top field1 field2 value1 value2|
   552 	|application top field1 field2 value1 value2|
   449 
   553 
   450         application := Plug new.
   554 	application := Plug new.
   451         application respondTo:#value1Changed
   555 	application respondTo:#value1Changed
   452                          with:[value2 value:(value1 value isNil ifTrue:[nil]
   556 			 with:[value2 value:(value1 value isNil ifTrue:[nil]
   453                                                                 ifFalse:[value1 value squared])].
   557 								ifFalse:[value1 value squared])].
   454 
   558 
   455         value1 := 1 asValue.
   559 	value1 := 1 asValue.
   456         value2 := 1 asValue.
   560 	value2 := 1 asValue.
   457 
   561 
   458         top := Dialog new.
   562 	top := Dialog new.
   459         top extent:200@200.
   563 	top extent:200@200.
   460 
   564 
   461         (top addTextLabel:'some number:') layout:#left.
   565 	(top addTextLabel:'some number:') layout:#left.
   462         top addVerticalSpace.
   566 	top addVerticalSpace.
   463 
   567 
   464         (top addInputFieldOn:value1 tabable:false) 
   568 	(top addInputFieldOn:value1 tabable:false) 
   465             converter:(PrintConverter new initForNumberOrNil);
   569 	    converter:(PrintConverter new initForNumberOrNil);
   466             immediateAccept:true.
   570 	    immediateAccept:true.
   467         top addVerticalSpace.
   571 	top addVerticalSpace.
   468 
   572 
   469         (top addTextLabel:'squared:') layout:#left.
   573 	(top addTextLabel:'squared:') layout:#left.
   470         top addVerticalSpace.
   574 	top addVerticalSpace.
   471         (top addInputFieldOn:value2 tabable:false) 
   575 	(top addInputFieldOn:value2 tabable:false) 
   472             converter:(PrintConverter new initForNumberOrNil).
   576 	    converter:(PrintConverter new initForNumberOrNil).
   473 
   577 
   474         value1 onChangeSend:#value1Changed to:application.
   578 	value1 onChangeSend:#value1Changed to:application.
   475 
   579 
   476         top openModeless.
   580 	top openModeless.
   477 
   581 
   478 
   582 
   479     two-way connect:
   583     two-way connect:
   480     each field updates the other (notice, that we have to turn off
   584     each field updates the other (notice, that we have to turn off
   481     onChange: notification, to avoid an endless notification cycle)
   585     onChange: notification, to avoid an endless notification cycle)
   482 
   586 
   483         |application top field1 field2 value1 value2|
   587 	|application top field1 field2 value1 value2|
   484 
   588 
   485         application := Plug new.
   589 	application := Plug new.
   486         application respondTo:#value1Changed
   590 	application respondTo:#value1Changed
   487                          with:[value2 retractInterestsFor:application.
   591 			 with:[value2 retractInterestsFor:application.
   488                                value2 value:(value1 value isNil ifTrue:[nil]
   592 			       value2 value:(value1 value isNil ifTrue:[nil]
   489                                                                 ifFalse:[value1 value squared]).
   593 								ifFalse:[value1 value squared]).
   490                                value2 onChangeSend:#value2Changed to:application.
   594 			       value2 onChangeSend:#value2Changed to:application.
   491                               ].
   595 			      ].
   492         application respondTo:#value2Changed
   596 	application respondTo:#value2Changed
   493                          with:[value1 retractInterestsFor:application.
   597 			 with:[value1 retractInterestsFor:application.
   494                                value1 value:(value2 value isNil ifTrue:[nil]
   598 			       value1 value:(value2 value isNil ifTrue:[nil]
   495                                                                 ifFalse:[value2 value sqrt]).
   599 								ifFalse:[value2 value sqrt]).
   496                                value1 onChangeSend:#value1Changed to:application.
   600 			       value1 onChangeSend:#value1Changed to:application.
   497                               ].
   601 			      ].
   498 
   602 
   499         value1 := 1 asValue.
   603 	value1 := 1 asValue.
   500         value2 := 1 asValue.
   604 	value2 := 1 asValue.
   501 
   605 
   502         top := Dialog new.
   606 	top := Dialog new.
   503         top extent:200@200.
   607 	top extent:200@200.
   504 
   608 
   505         (top addTextLabel:'some number:') layout:#left.
   609 	(top addTextLabel:'some number:') layout:#left.
   506         top addVerticalSpace.
   610 	top addVerticalSpace.
   507 
   611 
   508         (top addInputFieldOn:value1 tabable:false) 
   612 	(top addInputFieldOn:value1 tabable:false) 
   509             converter:(PrintConverter new initForNumberOrNil);
   613 	    converter:(PrintConverter new initForNumberOrNil);
   510             immediateAccept:true.
   614 	    immediateAccept:true.
   511         top addVerticalSpace.
   615 	top addVerticalSpace.
   512 
   616 
   513         (top addTextLabel:'squared:') layout:#left.
   617 	(top addTextLabel:'squared:') layout:#left.
   514         top addVerticalSpace.
   618 	top addVerticalSpace.
   515         (top addInputFieldOn:value2 tabable:false) 
   619 	(top addInputFieldOn:value2 tabable:false) 
   516             converter:(PrintConverter new initForNumberOrNil);
   620 	    converter:(PrintConverter new initForNumberOrNil);
   517             immediateAccept:true.
   621 	    immediateAccept:true.
   518 
   622 
   519         value1 onChangeSend:#value1Changed to:application.
   623 	value1 onChangeSend:#value1Changed to:application.
   520         value2 onChangeSend:#value2Changed to:application.
   624 	value2 onChangeSend:#value2Changed to:application.
   521 
   625 
   522         top openModeless.
   626 	top openModeless.
   523 "
   627 "
   524 ! !
   628 ! !
   525 
   629 
   526 !EditField class methodsFor:'defaults'!
   630 !EditField class methodsFor:'defaults'!
   527 
   631 
   551     "
   655     "
   552      self updateStyleCache
   656      self updateStyleCache
   553     "
   657     "
   554 ! !
   658 ! !
   555 
   659 
       
   660 !EditField methodsFor:'accepting'!
       
   661 
       
   662 accept
       
   663     ""
       
   664     |val string|
       
   665 
       
   666     super accept.
       
   667     converter notNil ifTrue:[
       
   668 	val := self editValue.
       
   669 	string := converter printStringFor:val.
       
   670 	string ~= self contents ifTrue:[
       
   671 	    self contents:string.
       
   672 	    self flash
       
   673 	]
       
   674     ].
       
   675 ! !
       
   676 
   556 !EditField methodsFor:'accessing-behavior'!
   677 !EditField methodsFor:'accessing-behavior'!
   557 
   678 
   558 acceptOnLeave:aBoolean
   679 acceptOnLeave:aBoolean
   559     "set/clear the acceptOnLeave flag. The default is false.
   680     "set/clear the acceptOnLeave flag. The default is false.
   560      If true, leaving the box (via return, cursor etc) accepts my 
   681      If true, leaving the box (via return, cursor etc) accepts my 
   574      acceptOnReturn := aBoolean
   695      acceptOnReturn := aBoolean
   575 
   696 
   576     "Modified: 16.12.1995 / 16:25:34 / cg"
   697     "Modified: 16.12.1995 / 16:25:34 / cg"
   577 !
   698 !
   578 
   699 
       
   700 autoScroll:aBoolean
       
   701     "turn on/off automatic scrolling upon keyboard entry
       
   702      to make the cursor visible."
       
   703 
       
   704     autoScrollHorizontally := aBoolean
       
   705 !
       
   706 
   579 crAction:aBlock
   707 crAction:aBlock
   580     "define an action to be evaluated when the return key is pressed."
   708     "define an action to be evaluated when the return key is pressed."
   581 
   709 
   582     crAction := aBlock
   710     crAction := aBlock
   583 !
   711 !
   584 
   712 
   585 cursorMovementWhenUpdating:aSymbol
   713 cursorMovementWhenUpdating:aSymbol
   586     "define what should be done with the cursor, when I update
   714     "define what should be done with the cursor, when I update
   587      my contents from the model. Allowed arguments are:
   715      my contents from the model. Allowed arguments are:
   588         #keep / nil     -> stay where it was
   716 	#keep / nil     -> stay where it was
   589         #endOfLine      -> position cursor after the string
   717 	#endOfLine      -> position cursor after the string
   590         #beginOfLine    -> position cursor to the beginning
   718 	#beginOfLine    -> position cursor to the beginning
   591      The default is #endOfLine.
   719      The default is #endOfLine.
   592      This may be useful for fields which get new values assigned from
   720      This may be useful for fields which get new values assigned from
   593      the program (i.e. not from the user)"
   721      the program (i.e. not from the user)"
   594 
   722 
   595     cursorMovementWhenUpdating := aSymbol
   723     cursorMovementWhenUpdating := aSymbol
   599 
   727 
   600 disable
   728 disable
   601     "disable the field; hide the cursor and ignore input"
   729     "disable the field; hide the cursor and ignore input"
   602 
   730 
   603     enabled ifTrue:[
   731     enabled ifTrue:[
   604         enabled := false.
   732 	enabled := false.
   605         self hideCursor
   733 	self hideCursor
   606     ]
   734     ]
   607 
   735 
   608     "Modified: 16.12.1995 / 16:28:05 / cg"
   736     "Modified: 16.12.1995 / 16:28:05 / cg"
   609 !
   737 !
   610 
   738 
   613 
   741 
   614     enabled ifFalse:[
   742     enabled ifFalse:[
   615 "/        enableAction notNil ifTrue:[
   743 "/        enableAction notNil ifTrue:[
   616 "/            enableAction value
   744 "/            enableAction value
   617 "/        ].
   745 "/        ].
   618         enabled := true.
   746 	enabled := true.
   619         super showCursor
   747 	super showCursor
   620     ]
   748     ]
   621 
   749 
   622     "Modified: 16.12.1995 / 16:28:09 / cg"
   750     "Modified: 16.12.1995 / 16:28:09 / cg"
   623 !
   751 !
   624 
   752 
   680 
   808 
   681 enableChannel:aValueHolder 
   809 enableChannel:aValueHolder 
   682     |wasEnabled|
   810     |wasEnabled|
   683 
   811 
   684     enableChannel notNil ifTrue:[
   812     enableChannel notNil ifTrue:[
   685         wasEnabled := enableChannel value.
   813 	wasEnabled := enableChannel value.
   686         enableChannel retractInterestsFor:self. 
   814 	enableChannel retractInterestsFor:self. 
   687     ] ifFalse:[
   815     ] ifFalse:[
   688         wasEnabled := enabled
   816 	wasEnabled := enabled
   689     ].
   817     ].
   690     enableChannel := aValueHolder.
   818     enableChannel := aValueHolder.
   691     aValueHolder onChangeSend:#enableStateChange to:self.
   819     aValueHolder onChangeSend:#enableStateChange to:self.
   692     enableChannel value ~~ wasEnabled ifTrue:[
   820     enableChannel value ~~ wasEnabled ifTrue:[
   693         self enableStateChange
   821 	self enableStateChange
   694     ]
   822     ]
   695 
   823 
   696     "Created: 16.12.1995 / 16:35:32 / cg"
   824     "Created: 16.12.1995 / 16:35:32 / cg"
   697 ! !
   825 ! !
   698 
   826 
   852 
   980 
   853 maxChars:aNumberOrNil
   981 maxChars:aNumberOrNil
   854     "set the maximum number of characters that are allowed in
   982     "set the maximum number of characters that are allowed in
   855      the field. Additional input will be ignored by the field.
   983      the field. Additional input will be ignored by the field.
   856      A limit of nil means: unlimited. This is the default.
   984      A limit of nil means: unlimited. This is the default.
       
   985      If set, a lengthLimit must be defined before any contents is placed
       
   986      into the field, because the contents is not cut when the max is
       
   987      changed later. I.e. it should be set early after creation of the field.
       
   988 
   857      This method has been renamed from #lengthLimit: for ST-80
   989      This method has been renamed from #lengthLimit: for ST-80
   858      compatibility."
   990      compatibility."
   859 
   991 
   860     lengthLimit := aNumberOrNil
   992     lengthLimit := aNumberOrNil.
   861 !
   993 !
   862 
   994 
   863 passwordCharacter
   995 passwordCharacter
   864     "return the passwordCharacter;
   996     "return the passwordCharacter;
   865      If nonNil, that one is replacing typed input
   997      If nonNil, that one is replacing typed input
   968     ^ true
  1100     ^ true
   969 !
  1101 !
   970 
  1102 
   971 enableStateChange
  1103 enableStateChange
   972     enableChannel value ifTrue:[
  1104     enableChannel value ifTrue:[
   973         self enable
  1105 	self enable
   974     ] ifFalse:[
  1106     ] ifFalse:[
   975         self disable
  1107 	self disable
   976     ].
  1108     ].
   977 
  1109 
   978     "Created: 16.12.1995 / 16:35:39 / cg"
  1110     "Created: 16.12.1995 / 16:35:39 / cg"
   979     "Modified: 16.12.1995 / 16:36:13 / cg"
  1111     "Modified: 16.12.1995 / 16:36:13 / cg"
   980 !
  1112 !
   997     "if keyHandler is defined, pass input; otherwise check for leave
  1129     "if keyHandler is defined, pass input; otherwise check for leave
   998      keys"
  1130      keys"
   999 
  1131 
  1000     <resource: #keyboard (#DeleteLine #EndOfText)>
  1132     <resource: #keyboard (#DeleteLine #EndOfText)>
  1001 
  1133 
  1002     |leave xCol newOffset oldWidth newWidth s|
  1134     |leave xCol newOffset newWidth s|
  1003 
  1135 
  1004     enabled ifFalse:[
  1136     enabled ifFalse:[
  1005         ^ self
  1137 	^ self
  1006     ].
  1138     ].
  1007 
  1139 
  1008     (key == #DeleteLine) ifTrue:[
  1140     (key == #DeleteLine) ifTrue:[
  1009         Smalltalk at:#CopyBuffer put:(self contents).
  1141 	Smalltalk at:#CopyBuffer put:(self contents).
  1010         self contents:''. ^ self
  1142 	self contents:''. ^ self
  1011     ].
  1143     ].
  1012 
  1144 
  1013     (key == #Tab) ifTrue:[
  1145     (key == #Tab) ifTrue:[
  1014         tabAction notNil ifTrue:[tabAction value. ^ self].
  1146 	tabAction notNil ifTrue:[tabAction value. ^ self].
  1015         entryCompletionBlock notNil ifTrue:[
  1147 	entryCompletionBlock notNil ifTrue:[
  1016             s := self contents.
  1148 	    s := self contents.
  1017             s isNil ifTrue:[
  1149 	    s isNil ifTrue:[
  1018                 s := ''
  1150 		s := ''
  1019             ] ifFalse:[
  1151 	    ] ifFalse:[
  1020                 s := s asString
  1152 		s := s asString
  1021             ].
  1153 	    ].
  1022             entryCompletionBlock value:s. ^ self
  1154 	    entryCompletionBlock value:s. ^ self
  1023         ]
  1155 	]
  1024     ].
  1156     ].
  1025     (key == #Return) ifTrue:[
  1157     (key == #Return) ifTrue:[
  1026         crAction notNil ifTrue:[crAction value. ^ self].
  1158 	crAction notNil ifTrue:[crAction value. ^ self].
  1027     ].
  1159     ].
  1028     leave := leaveKeys includes:key.
  1160     leave := leaveKeys includes:key.
  1029     leave ifTrue:[
  1161     leave ifTrue:[
  1030 
  1162 
  1031         ((key == #Return and:[acceptOnReturn])
  1163 	((key == #Return and:[acceptOnReturn])
  1032         or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
  1164 	or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
  1033             self accept.
  1165 	    self accept.
  1034         ].
  1166 	].
  1035 
  1167 
  1036         leaveAction notNil ifTrue:[
  1168 	leaveAction notNil ifTrue:[
  1037             ^ leaveAction value:key
  1169 	    ^ leaveAction value:key
  1038         ].
  1170 	].
  1039 
  1171 
  1040         x >= 0 ifTrue:[
  1172 	x >= 0 ifTrue:[
  1041             "
  1173 	    "
  1042              let superview know about the leave ...
  1174 	     let superview know about the leave ...
  1043              This is a temporary kludge for the tableWidget -
  1175 	     This is a temporary kludge for the tableWidget -
  1044              it is no clean coding style. Should make the tableWidget
  1176 	     it is no clean coding style. Should make the tableWidget
  1045              a proper model and handle it via the changed mechanism ....
  1177 	     a proper model and handle it via the changed mechanism ....
  1046             "
  1178 	    "
  1047             (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
  1179 	    (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
  1048                 superView keyPress:key x:x y:y.
  1180 		superView keyPress:key x:x y:y.
  1049             ].
  1181 	    ].
  1050         ].
  1182 	].
  1051         ^ self
  1183 	^ self
  1052     ].
  1184     ].
  1053 
  1185 
  1054     "
  1186     "
  1055      ignore some keys (if not a leaveKey) ...
  1187      ignore some keys (if not a leaveKey) ...
  1056     "
  1188     "
  1060     (key == #GotoLine) ifTrue:[^self].
  1192     (key == #GotoLine) ifTrue:[^self].
  1061 
  1193 
  1062     "
  1194     "
  1063      a normal key - let superclass's method insert it
  1195      a normal key - let superclass's method insert it
  1064     "
  1196     "
  1065     oldWidth := self widthOfContents.
       
  1066     super keyPress:key x:x y:y.
  1197     super keyPress:key x:x y:y.
  1067 
  1198 
  1068     "
  1199     "
  1069      for end-of-text, also move to end-of-line
  1200      for end-of-text, also move to end-of-line
  1070     "
  1201     "
  1071     key == #EndOfText ifTrue:[
  1202     key == #EndOfText ifTrue:[
  1072         super keyPress:#EndOfLine x:x y:y.
  1203 	super keyPress:#EndOfLine x:x y:y.
  1073     ].
  1204     ].
       
  1205 
       
  1206     self resizeOrScroll.
       
  1207 
       
  1208     "Modified: 16.1.1996 / 19:39:14 / cg"
       
  1209 !
       
  1210 
       
  1211 resizeOrScroll
       
  1212     "helper for keyPress.
       
  1213      Extracted for easier subclass redefinition."
       
  1214 
       
  1215     |xCol newOffset newWidth|
       
  1216 
  1074     newWidth := self widthOfContents.
  1217     newWidth := self widthOfContents.
  1075 
  1218 
  1076     "
  1219     "
  1077      should (& can) we resize ?
  1220      should (& can) we resize ?
  1078     "
  1221     "
  1079     xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
  1222     xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
  1080     (xCol > (width * (5/6))) ifTrue:[
  1223     (xCol > (width * (5/6))) ifTrue:[
  1081         self changed:#preferredExtent
  1224 	self changed:#preferredExtent
  1082     ] ifFalse:[
  1225     ] ifFalse:[
  1083         newWidth < (width * (1/6)) ifTrue:[
  1226 	newWidth < (width * (1/6)) ifTrue:[
  1084             self changed:#preferredExtent
  1227 	    self changed:#preferredExtent
  1085         ]
  1228 	]
  1086     ].
  1229     ].
  1087 
  1230 
  1088     "
  1231     autoScrollHorizontally ifTrue:[
  1089      did someone react (i.e. has my extent changed) ?
  1232 	"
  1090      (if not, we scroll horizontally)
  1233 	 did someone react (i.e. has my extent changed) ?
  1091     "
  1234 	 (if not, we scroll horizontally)
  1092     xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
  1235 	"
  1093     (xCol > (width * (5/6))) ifTrue:[
  1236 	xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
  1094         newOffset := leftOffset + (width // 2).
  1237 	(xCol > (width * (5/6))) ifTrue:[
  1095     ] ifFalse:[
  1238 	    newOffset := leftOffset + (width // 2).
  1096         (xCol < (width * (1/6))) ifTrue:[
  1239 	] ifFalse:[
  1097             newOffset := 0 max: leftOffset - (width // 2).
  1240 	    (xCol < (width * (1/6))) ifTrue:[
  1098         ] ifFalse:[
  1241 		newOffset := 0 max: leftOffset - (width // 2).
  1099             newOffset := leftOffset
  1242 	    ] ifFalse:[
  1100         ]
  1243 		newOffset := leftOffset
  1101     ].
  1244 	    ]
  1102     newOffset ~~ leftOffset ifTrue:[
  1245 	].
  1103         self scrollHorizontalTo:newOffset.
  1246 	newOffset ~~ leftOffset ifTrue:[
  1104 "/        leftOffset := newOffset.
  1247 	    self scrollHorizontalTo:newOffset.
  1105 "/        self clear.
  1248 	]
  1106 "/        self redraw
  1249     ].
  1107     ]
       
  1108 ! !
  1250 ! !
  1109 
  1251 
  1110 !EditField methodsFor:'initialization'!
  1252 !EditField methodsFor:'initialization'!
  1111 
  1253 
  1112 editMenu
  1254 editMenu
  1164 initialize
  1306 initialize
  1165     super initialize.
  1307     super initialize.
  1166     self height:(font height + font descent + (topMargin * 2)).
  1308     self height:(font height + font descent + (topMargin * 2)).
  1167     enabled := true.
  1309     enabled := true.
  1168     fixedSize := true.
  1310     fixedSize := true.
       
  1311     autoScrollHorizontally := true.
  1169     nFullLinesShown := 1.
  1312     nFullLinesShown := 1.
  1170     nLinesShown := 1.
  1313     nLinesShown := 1.
  1171     immediateAccept := false.
  1314     immediateAccept := false.
  1172 "/    acceptOnLeave := false.
  1315 "/    acceptOnLeave := false.
  1173 "/    acceptOnReturn := false.
  1316 "/    acceptOnReturn := false.
  1316 ! !
  1459 ! !
  1317 
  1460 
  1318 !EditField class methodsFor:'documentation'!
  1461 !EditField class methodsFor:'documentation'!
  1319 
  1462 
  1320 version
  1463 version
  1321     ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.37 1996-01-10 14:48:41 ca Exp $'
  1464     ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.38 1996-01-16 19:07:53 cg Exp $'
  1322 ! !
  1465 ! !