--- a/EditField.st Wed May 10 04:30:46 1995 +0200
+++ b/EditField.st Fri May 12 20:25:18 1995 +0200
@@ -14,11 +14,11 @@
EditTextView subclass:#EditField
instanceVariableNames:'leaveAction enabled enableAction crAction tabAction converter
- leaveKeys immediateAccept acceptOnLeave acceptOnReturn
- lengthLimit'
+ leaveKeys immediateAccept acceptOnLeave acceptOnReturn
+ lengthLimit'
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
- DefaultSelectionForegroundColor DefaultSelectionBackgroundColor
- DefaultFont'
+ DefaultSelectionForegroundColor DefaultSelectionBackgroundColor
+ DefaultFont'
poolDictionaries:''
category:'Views-Text'
!
@@ -27,7 +27,7 @@
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.21 1995-05-09 01:55:33 claus Exp $
+$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.22 1995-05-12 18:23:59 claus Exp $
'!
!EditField class methodsFor:'documentation'!
@@ -48,7 +48,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.21 1995-05-09 01:55:33 claus Exp $
+$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.22 1995-05-12 18:23:59 claus Exp $
"
!
@@ -280,6 +280,8 @@
top open.
+
+
use a model:
(see changing model value in inspector when return is pressed in the field)
@@ -300,7 +302,7 @@
model inspect.
- two views on the same model:
+ two views on the same model (each accepts on return):
|top1 top2 field1 field2 model|
@@ -324,6 +326,30 @@
field2 model:model.
top2 open.
+ two views on the same model (no accept on return):
+
+ |top1 top2 field1 field2 model|
+
+ model := 'hello world' asValue.
+
+ top1 := StandardSystemView new.
+ top1 extent:200@100.
+ field1 := EditField origin:0.0@ViewSpacing in:top1.
+ field1 width:1.0.
+ field1 leftInset:ViewSpacing;
+ rightInset:ViewSpacing.
+ field1 model:model; acceptOnReturn:false.
+ top1 open.
+
+ top2 := StandardSystemView new.
+ top2 extent:200@100.
+ field2 := EditField origin:0.0@ViewSpacing in:top2.
+ field2 width:1.0.
+ field2 leftInset:ViewSpacing;
+ rightInset:ViewSpacing.
+ field2 model:model; acceptOnReturn:false.
+ top2 open.
+
with immediate accept:
|top1 top2 field1 field2 model|
@@ -446,7 +472,8 @@
(top addTextLabel:'squared:') layout:#left.
top addVerticalSpace.
(top addInputFieldOn:value2 tabable:false)
- converter:(PrintConverter new initForNumberOrNil).
+ converter:(PrintConverter new initForNumberOrNil);
+ immediateAccept:true.
value1 onChangeSend:#value1Changed to:application.
value2 onChangeSend:#value2Changed to:application.
@@ -519,6 +546,12 @@
]
!
+argForChangeMessage
+ "redefined to send use converted value (if I have one)"
+
+ ^ self editValue
+!
+
startAutoScrollUp:y
"no vertical scrolling in editfields"
@@ -883,43 +916,43 @@
|leave xCol newOffset oldWidth newWidth|
enabled ifFalse:[
- ^ self
+ ^ self
].
(key == #DeleteLine) ifTrue:[
- Smalltalk at:#CopyBuffer put:(self contents).
- self contents:''. ^ self
+ Smalltalk at:#CopyBuffer put:(self contents).
+ self contents:''. ^ self
].
(key == #Tab) ifTrue:[
- tabAction notNil ifTrue:[tabAction value. ^ self].
+ tabAction notNil ifTrue:[tabAction value. ^ self].
].
(key == #Return) ifTrue:[
- crAction notNil ifTrue:[crAction value. ^ self].
+ crAction notNil ifTrue:[crAction value. ^ self].
].
leave := leaveKeys includes:key.
leave ifTrue:[
- leaveAction notNil ifTrue:[
- leaveAction value:key
- ].
+ leaveAction notNil ifTrue:[
+ leaveAction value:key
+ ].
- ((key == #Return and:[acceptOnReturn])
- or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
- self accept.
- ].
+ ((key == #Return and:[acceptOnReturn])
+ or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
+ self accept.
+ ].
- x >= 0 ifTrue:[
- "
- let superview know about the leave ...
- This is a temporary kludge for the tableWidget -
- it is no clean coding style. Should make the tableWidget
- a proper model and handle it via the changed mechanism ....
- "
- (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
- superView keyPress:key x:x y:y.
- ].
- ].
- ^ self
+ x >= 0 ifTrue:[
+ "
+ let superview know about the leave ...
+ This is a temporary kludge for the tableWidget -
+ it is no clean coding style. Should make the tableWidget
+ a proper model and handle it via the changed mechanism ....
+ "
+ (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
+ superView keyPress:key x:x y:y.
+ ].
+ ].
+ ^ self
].
"
@@ -940,7 +973,7 @@
for end-of-text, also move to end-of-line
"
key == #EndOfText ifTrue:[
- super keyPress:#EndOfLine x:x y:y.
+ super keyPress:#EndOfLine x:x y:y.
].
newWidth := self widthOfContents.
@@ -949,11 +982,11 @@
"
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
(xCol > (width * (5/6))) ifTrue:[
- self changed:#preferedExtent
+ self changed:#preferedExtent
] ifFalse:[
- newWidth < (width * (1/6)) ifTrue:[
- self changed:#preferedExtent
- ]
+ newWidth < (width * (1/6)) ifTrue:[
+ self changed:#preferedExtent
+ ]
].
"
@@ -962,18 +995,18 @@
"
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
(xCol > (width * (5/6))) ifTrue:[
- newOffset := leftOffset + (width // 2).
+ newOffset := leftOffset + (width // 2).
] ifFalse:[
- (xCol < (width * (1/6))) ifTrue:[
- newOffset := 0 max: leftOffset - (width // 2).
- ] ifFalse:[
- newOffset := leftOffset
- ]
+ (xCol < (width * (1/6))) ifTrue:[
+ newOffset := 0 max: leftOffset - (width // 2).
+ ] ifFalse:[
+ newOffset := leftOffset
+ ]
].
newOffset ~~ leftOffset ifTrue:[
- leftOffset := newOffset.
- self clear.
- self redraw
+ leftOffset := newOffset.
+ self clear.
+ self redraw
]
!