diff -r 08eec8838a4c -r 932fa5ca44f8 EditField.st --- a/EditField.st Thu Jan 18 22:29:07 1996 +0100 +++ b/EditField.st Wed Jan 24 13:37:49 1996 +0100 @@ -14,7 +14,8 @@ instanceVariableNames:'leaveAction enabled enableAction crAction tabAction converter leaveKeys immediateAccept acceptOnLeave acceptOnReturn lengthLimit entryCompletionBlock passwordCharacter - cursorMovementWhenUpdating enableChannel autoScrollHorizontally' + cursorMovementWhenUpdating enableChannel autoScrollHorizontally + acceptOnTab' classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultSelectionForegroundColor DefaultSelectionBackgroundColor DefaultFont' @@ -138,6 +139,33 @@ acceptOnReturn if true, leaving the field via return automatically accepts the value into the model. Default is true. + + acceptOnTab if true, the Tab key accepts and leaves the field. + If false, Tabs are entered into the contents field like + ordinary non-control keys. + Default is true. + + lengthLimit the max. number of allowed characters + + entryCompletionBlock if non-nil, this is evaluated to complete the entry + when Tab is pressed. + Entry completion is used with Filenamefields or in the + browser for classname/selector completion. + This feature is disabled when acceptOnTab is true. + + passwordCharacter if non-nil, typed input is replaced by this character + for display. Used for secret-input fields (such as password entry). + Default is nil. + + + cursorMovementWhenUpdating defines where the cursor is to be positioned if the + model changes its value by some outside activity + (i.e. not by user input into the field). + Can be one of: + #keep / nil -> stay where it was + #endOfLine -> position cursor after the string + #beginOfLine -> position cursor to the beginning + The default is nil (i.e. stay where it was before). " ! @@ -543,6 +571,50 @@ model inspect. + multiple editFields on multiple models (value holders): + (the fields are connected by a group to allow tabbing) + + |top panel group field1 field2 field3 box v1 v2 v3| + + v1 := true asValue. + v2 := 'some string' asValue. + v3 := 1.2 asValue. + + top := StandardSystemView new. + top extent:200@100. + + panel := VerticalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. + + field1 := EditField new. + field1 width:1.0. + field1 horizontalInset:ViewSpacing. + field1 converter:(PrintConverter new initForYesNo). + field1 model:v1. + panel add:field1. + + field2 := EditField new. + field2 width:1.0. + field2 horizontalInset:ViewSpacing. + field2 model:v2. + panel add:field2. + + field3 := EditField new. + field3 width:1.0. + field3 horizontalInset:ViewSpacing. + field3 converter:(PrintConverter new initForNumber). + field3 model:v3. + panel add:field3. + + group := EnterFieldGroup new. + group add:field1; add:field2; add:field3. + + top openModal. + + Transcript showCr:v1 value. + Transcript showCr:v2 value. + Transcript showCr:v3 value. + + connecting fields: update field2 wehenever field1 is changed. (normally, the processing below (xChanged) is done in your application @@ -697,6 +769,17 @@ "Modified: 16.12.1995 / 16:25:34 / cg" ! +acceptOnTab:aBoolean + "set/clear the acceptOnTab flag. The default is true. + If true, a pressed Tab key accepts and leaves the box. + If false, the Tab key is treated like any normal input character + (i.e. inserted into the contents)." + + acceptOnTab := aBoolean + + "Created: 24.1.1996 / 13:13:37 / cg" +! + autoScroll:aBoolean "turn on/off automatic scrolling upon keyboard entry to make the cursor visible." @@ -740,9 +823,6 @@ "enable the field; show the cursor and allow input" enabled ifFalse:[ -"/ enableAction notNil ifTrue:[ -"/ enableAction value -"/ ]. enabled := true. super showCursor ] @@ -1142,26 +1222,31 @@ self contents:''. ^ self ]. + leave := leaveKeys includes:key. + (key == #Tab) ifTrue:[ tabAction notNil ifTrue:[tabAction value. ^ self]. - entryCompletionBlock notNil ifTrue:[ - s := self contents. - s isNil ifTrue:[ - s := '' - ] ifFalse:[ - s := s asString - ]. - entryCompletionBlock value:s. ^ self + acceptOnTab ifTrue:[ + leave := true + ] ifFalse:[ + entryCompletionBlock notNil ifTrue:[ + s := self contents. + s isNil ifTrue:[ + s := '' + ] ifFalse:[ + s := s asString + ]. + entryCompletionBlock value:s. ^ self + ] ] ]. (key == #Return) ifTrue:[ crAction notNil ifTrue:[crAction value. ^ self]. ]. - leave := leaveKeys includes:key. leave ifTrue:[ - ((key == #Return and:[acceptOnReturn]) - or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[ + or:[(key == #Tab and:[acceptOnTab]) + or:[key ~~ #Return and:[acceptOnLeave]]]) ifTrue:[ self accept. ]. @@ -1312,9 +1397,7 @@ nFullLinesShown := 1. nLinesShown := 1. immediateAccept := false. -"/ acceptOnLeave := false. -"/ acceptOnReturn := false. - acceptOnLeave := acceptOnReturn := true. + acceptOnLeave := acceptOnReturn := acceptOnTab := true. cursorShown := true. leaveKeys := self class defaultLeaveKeys. cursorMovementWhenUpdating := #endOfLine @@ -1461,5 +1544,5 @@ !EditField class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.38 1996-01-16 19:07:53 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.39 1996-01-24 12:37:49 ah Exp $' ! !