equal
deleted
inserted
replaced
11 " |
11 " |
12 |
12 |
13 EditTextView subclass:#EditField |
13 EditTextView subclass:#EditField |
14 instanceVariableNames:'leaveAction enabled clickAction crAction tabAction converter |
14 instanceVariableNames:'leaveAction enabled clickAction crAction tabAction converter |
15 leaveKeys immediateAccept acceptOnLeave acceptOnReturn |
15 leaveKeys immediateAccept acceptOnLeave acceptOnReturn |
16 lengthLimit entryCompletionBlock passwordCharacter |
16 lengthLimit entryCompletionBlock entryCompletionCharacter passwordCharacter |
17 cursorMovementWhenUpdating enableChannel autoScrollHorizontally |
17 cursorMovementWhenUpdating enableChannel autoScrollHorizontally |
18 acceptOnTab acceptOnLostFocus' |
18 acceptOnTab acceptOnLostFocus' |
19 classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
19 classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
20 DefaultSelectionForegroundColor DefaultSelectionBackgroundColor' |
20 DefaultSelectionForegroundColor DefaultSelectionBackgroundColor' |
21 poolDictionaries:'' |
21 poolDictionaries:'' |
146 Default is true. |
146 Default is true. |
147 |
147 |
148 lengthLimit <Number> the max. number of allowed characters |
148 lengthLimit <Number> the max. number of allowed characters |
149 |
149 |
150 entryCompletionBlock <BlockOrNil> if non-nil, this is evaluated to complete the entry |
150 entryCompletionBlock <BlockOrNil> if non-nil, this is evaluated to complete the entry |
151 when Tab is pressed. |
151 when <entryCompletionCharacter> is pressed. |
152 Entry completion is used with Filenamefields or in the |
152 Entry completion is used with Filenamefields or in the |
153 browser for classname/selector completion. |
153 browser for classname/selector completion. |
154 Setting a nonNil entryCompletion disables acceptOnTab. |
154 Setting a nonNil entryCompletion disables acceptOnTab. |
|
155 |
|
156 entryCompletionCharacter <CharacterOrNil> if non-nil AND entryCompletionBlock is nonNil, that one |
|
157 is evaluated for completion. Typically used to complete |
|
158 a fileName (also, classNames in the browser) |
|
159 Default is #Tab. |
155 |
160 |
156 passwordCharacter <CharacterOrNil> if non-nil, typed input is replaced by this character |
161 passwordCharacter <CharacterOrNil> if non-nil, typed input is replaced by this character |
157 for display. Used for secret-input fields (such as password entry). |
162 for display. Used for secret-input fields (such as password entry). |
158 Default is nil. |
163 Default is nil. |
159 |
164 |
1358 |
1363 |
1359 <resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev |
1364 <resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev |
1360 #DeleteLine #GotoLine #EndOfLine #EndOfText |
1365 #DeleteLine #GotoLine #EndOfLine #EndOfText |
1361 #CursorDown #CursorUp)> |
1366 #CursorDown #CursorUp)> |
1362 |
1367 |
1363 |leave xCol newOffset newWidth s| |
1368 |leave xCol newOffset newWidth s oldContents newContents| |
1364 |
1369 |
1365 enabled ifFalse:[ |
1370 enabled ifFalse:[ |
1366 ^ self |
1371 ^ self |
1367 ]. |
1372 ]. |
1368 |
1373 |
1370 Smalltalk at:#CopyBuffer put:(self contents). |
1375 Smalltalk at:#CopyBuffer put:(self contents). |
1371 self contents:''. ^ self |
1376 self contents:''. ^ self |
1372 ]. |
1377 ]. |
1373 |
1378 |
1374 leave := leaveKeys includes:key. |
1379 leave := leaveKeys includes:key. |
|
1380 |
|
1381 (key == entryCompletionCharacter |
|
1382 and:[entryCompletionBlock notNil]) ifTrue:[ |
|
1383 oldContents := self contents. |
|
1384 oldContents isNil ifTrue:[ |
|
1385 oldContents := '' |
|
1386 ] ifFalse:[ |
|
1387 oldContents := oldContents asString |
|
1388 ]. |
|
1389 |
|
1390 entryCompletionBlock value:oldContents. |
|
1391 |
|
1392 newContents := self contents. |
|
1393 newContents isNil ifTrue:[ |
|
1394 newContents := '' |
|
1395 ] ifFalse:[ |
|
1396 newContents := newContents asString |
|
1397 ]. |
|
1398 newContents ~= oldContents ifTrue:[ |
|
1399 self textChanged |
|
1400 ]. |
|
1401 (key ~~ #Tab) ifTrue:[^ self]. |
|
1402 ]. |
1375 |
1403 |
1376 (key == #Tab) ifTrue:[ |
1404 (key == #Tab) ifTrue:[ |
1377 tabAction notNil ifTrue:[ |
1405 tabAction notNil ifTrue:[ |
1378 "/ tab-hook. |
1406 "/ tab-hook. |
1379 acceptOnTab ifTrue:[ |
1407 acceptOnTab ifTrue:[ |
1381 ]. |
1409 ]. |
1382 tabAction value. |
1410 tabAction value. |
1383 ^ self |
1411 ^ self |
1384 ]. |
1412 ]. |
1385 |
1413 |
1386 entryCompletionBlock notNil ifTrue:[ |
1414 acceptOnTab ifTrue:[ |
1387 s := self contents. |
1415 self accept. |
1388 s isNil ifTrue:[ |
|
1389 s := '' |
|
1390 ] ifFalse:[ |
|
1391 s := s asString |
|
1392 ]. |
|
1393 entryCompletionBlock value:s. ^ self |
|
1394 ] ifFalse:[ |
|
1395 acceptOnTab ifTrue:[ |
|
1396 self accept. |
|
1397 ] |
|
1398 ]. |
1416 ]. |
1399 leave ifFalse:[ |
1417 leave ifFalse:[ |
1400 "/ forward it as a Focus-step |
1418 "/ forward it as a Focus-step |
1401 ^ super keyPress:#FocusNext x:x y:y |
1419 ^ super keyPress:#FocusNext x:x y:y |
1402 ] |
1420 ] |
1636 nLinesShown := 1. |
1654 nLinesShown := 1. |
1637 trimBlankLines := false. |
1655 trimBlankLines := false. |
1638 immediateAccept := false. |
1656 immediateAccept := false. |
1639 acceptOnLeave := acceptOnReturn := acceptOnTab := true. |
1657 acceptOnLeave := acceptOnReturn := acceptOnTab := true. |
1640 cursorShown := true. |
1658 cursorShown := true. |
|
1659 entryCompletionCharacter := #Tab. |
1641 |
1660 |
1642 leaveKeys isNil ifTrue:[ |
1661 leaveKeys isNil ifTrue:[ |
1643 leaveKeys := self class defaultLeaveKeys. |
1662 leaveKeys := self class defaultLeaveKeys. |
1644 ]. |
1663 ]. |
1645 cursorMovementWhenUpdating := #endOfLine |
1664 cursorMovementWhenUpdating := #endOfLine |
1772 tabMeansNextField |
1791 tabMeansNextField |
1773 "return true, if Tab character should shift focus to the next field" |
1792 "return true, if Tab character should shift focus to the next field" |
1774 |
1793 |
1775 "if I have a completionBlock, I want my Tabs ..." |
1794 "if I have a completionBlock, I want my Tabs ..." |
1776 |
1795 |
1777 ^ entryCompletionBlock isNil |
1796 ^ entryCompletionBlock isNil or:[entryCompletionCharacter ~~ #Tab] |
1778 |
1797 |
1779 "Created: 7.2.1996 / 19:16:38 / cg" |
1798 "Created: 7.2.1996 / 19:16:38 / cg" |
1780 ! ! |
1799 ! ! |
1781 |
1800 |
1782 !EditField methodsFor:'realization'! |
1801 !EditField methodsFor:'realization'! |
1814 ! ! |
1833 ! ! |
1815 |
1834 |
1816 !EditField class methodsFor:'documentation'! |
1835 !EditField class methodsFor:'documentation'! |
1817 |
1836 |
1818 version |
1837 version |
1819 ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.75 1997-01-22 17:19:05 cg Exp $' |
1838 ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.76 1997-01-28 10:33:25 cg Exp $' |
1820 ! ! |
1839 ! ! |