EditField.st
author tm
Mon, 28 Jun 1999 15:45:21 +0200
changeset 1936 f8253741114d
parent 1918 3ac07b97b4f7
child 1937 b88111019826
permissions -rw-r--r--
pointerLeave fixed
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
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    14
	instanceVariableNames:'leaveAction enabled clickAction 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
979
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
    16
		lengthLimit entryCompletionBlock entryCompletionCharacter
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
    17
		passwordCharacter cursorMovementWhenUpdating
979
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
    18
		autoScrollHorizontally acceptOnTab acceptOnLostFocus'
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    19
	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
392
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    20
		DefaultSelectionForegroundColor DefaultSelectionBackgroundColor'
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
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
    25
!EditField class methodsFor:'documentation'!
19
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
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    47
    Basically, an editField is an editor for a single line text,
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    48
    and provides the usual access protocol as defined in its superClasses
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    49
    (especially: #contents / #contents:).
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    50
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    51
    The above underlying internal mechanism can be used for fields which
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    52
    are passive; i.e. into which text can be entered and the value (string)
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    53
    is extracted actively by someone else.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    54
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    55
  accepting:
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    56
    The opposite way to use editFields is to connect them to a model
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    57
    and let the field notify changes to it.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    58
    This notification is called ``accepting''.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    59
    Unless accepted, the models value is not updated from the editFields contents
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    60
    this default is the normal operation and way things should work, since most
842
a27a1c6ddde0 Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
    61
    uses of editFields are not interested in every individual change
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    62
    (i.e. getting each keyStroke when a long number is entered).
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    63
    The default behavior is to ``accept'' when either return or a cursorUp/Down
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    64
    key is pressed in a field.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    65
    However, the field can setup to accept/not accept on leave, on return
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    66
    or on each individual key input.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    67
    See the methods #acceptOnLeave: / #acceptOnReturn: / #immediateAccept.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    68
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    69
    In addition, the set of keys which are considered ``leaveKeys'' can be
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    70
    specified by #leaveKeys: (in case you need keys other than Return, CursorUp/Down).
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    71
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    72
  models value vs. field contents:
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    73
    Although the field internally keeps its contents as some string object,
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    74
    the application may prefer to think of numbers, floats, yes/no values etc.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    75
    To support this, a converter may defined, which is responsible for conversion of
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    76
    strings to/from the models domain value.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    77
    If present (i.e. nonNil), the converter is asked to convert a string to the models
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    78
    domain with #readValueFrom:aString and vice versa, a value to a string by #printStringFor:.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    79
    The PrintConverter class already provides a number of standard conversions, see the examples.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    80
    To access a converted value directly (i.e. not via the model), use #editValue.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    81
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    82
  grouping:
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    83
    Individual fields do not know about being included in a group. This must be arranged on the
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    84
    outside, by placing multiple fields into an EnterFieldGroup.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    85
    This groupObject keeps a reference to one active field, and forwards input from any other
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    86
    field to the active one. Also have a look at the examples for this.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    87
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    88
  input completion:
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    89
    To support input completion (i.e. filename completion, classname completion etc.),
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    90
    a completionBlock can be defined which (if non-nil) is evaluated when the completion-key
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    91
    is pressed and its value is taken as the new field-contents. 
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    92
    The physical completion-key is the Tab key (this one cannot be defined by
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    93
    the keyboardTranslation mechanism, since that would disable the Tab-key on regular text views.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    94
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    95
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    96
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
    97
    [Instance variables:]
121
claus
parents: 120
diff changeset
    98
claus
parents: 120
diff changeset
    99
      leaveAction    <Block | nil>              if non-nil, this is evaluated with
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   100
                                                the key (#Return, #CursorUp etc.) when
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   101
                                                the field is left via keyboard keys.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   102
                                                (fieldGroups use this to decide which
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   103
                                                 field has to be enabled next)
121
claus
parents: 120
diff changeset
   104
claus
parents: 120
diff changeset
   105
      enabled        <Boolean>                  if false, input is ignored.
claus
parents: 120
diff changeset
   106
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   107
      clickAction    <Block | nil>              action performed if the field is
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   108
                                                clicked upon.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   109
                                                (this is used by the group to
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   110
                                                 set the active field to the clicked upon field)
121
claus
parents: 120
diff changeset
   111
claus
parents: 120
diff changeset
   112
      crAction       <Block | nil>              if non-nil, keyboard input of a cr are not
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   113
                                                handled specially, instead this block is evaluated
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   114
                                                (however, this block can perform additional checks and send
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   115
                                                 a #accept then)
121
claus
parents: 120
diff changeset
   116
claus
parents: 120
diff changeset
   117
      tabAction      <Block | nil>              if non-nil, keyboard input of a tab character
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   118
                                                is not entered into the text, instead this block
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   119
                                                is evaluated. Also, no input completion is performed if
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   120
                                                tabAction is nonNil.
121
claus
parents: 120
diff changeset
   121
claus
parents: 120
diff changeset
   122
      converter      <PrintConverter | nil>     if non-nil, this is supposed to convert between
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   123
                                                the object and its printed representation and vice versa.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   124
                                                Defaults to nil i.e. assume that strings are edited.
121
claus
parents: 120
diff changeset
   125
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   126
      leaveKeys      <Collection>               keys which are interpreted as 'leaving the field'
122
claus
parents: 121
diff changeset
   127
125
claus
parents: 122
diff changeset
   128
      immediateAccept   <Boolean>               if true, every change of the text is immediately
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   129
                                                forwarded to the model/acceptBlock. If false,
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   130
                                                the changed value is only stored in the model
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   131
                                                if the field is left or accepted.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   132
                                                Default is false.
122
claus
parents: 121
diff changeset
   133
claus
parents: 121
diff changeset
   134
      acceptOnLeave  <Boolean>                  if true, leaving the field (via cursor keys)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   135
                                                automatically accepts the value into the model.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   136
                                                Default is true.
122
claus
parents: 121
diff changeset
   137
claus
parents: 121
diff changeset
   138
      acceptOnReturn <Boolean>                  if true, leaving the field via return
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   139
                                                automatically accepts the value into the model.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   140
                                                Default is true.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   141
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   142
      acceptOnTab    <Boolean>                  if true, the Tab key accepts and leaves the field.
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   143
                                                If false, Tabs are entered into the contents field like
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   144
                                                ordinary non-control keys.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   145
                                                AcceptOnTab is ignored if the entryCompletion block is nonNil.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   146
                                                Default is true.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   147
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   148
      lengthLimit    <Number>                   the max. number of allowed characters
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   149
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   150
      entryCompletionBlock <BlockOrNil>         if non-nil, this is evaluated to complete the entry
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   151
                                                when <entryCompletionCharacter> is pressed.
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   152
                                                Entry completion is used with Filenamefields or in the
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   153
                                                browser for classname/selector completion.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   154
                                                Setting a nonNil entryCompletion disables acceptOnTab.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   155
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   156
      entryCompletionCharacter <CharacterOrNil>	if non-nil AND entryCompletionBlock is nonNil, that one
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   157
						is evaluated for completion. Typically used to complete
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   158
						a fileName (also, classNames in the browser)
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   159
						Default is #Tab.
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   160
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   161
      passwordCharacter     <CharacterOrNil>    if non-nil, typed input is replaced by this character
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   162
                                                for display. Used for secret-input fields (such as password entry).
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   163
                                                Default is nil.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   164
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   165
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   166
      cursorMovementWhenUpdating <Symbol>       defines where the cursor is to be positioned if the
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   167
                                                model changes its value by some outside activity
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   168
                                                (i.e. not by user input into the field).
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   169
                                                Can be one of:
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   170
                                                    #keep / nil     -> stay where it was
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   171
                                                    #endOfLine      -> position cursor after the string
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   172
                                                    #beginOfLine    -> position cursor to the beginning
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   173
                                                The default is nil (i.e. stay where it was before).
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   174
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   175
    [author:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   176
        Claus Gittinger
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   177
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   178
    [see also:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   179
        DialogBox
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   180
        EnterFieldGroup
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   181
        EnterBox EnterBox2
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   182
        FilenameEditField EditTextView
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
   183
"
120
claus
parents: 118
diff changeset
   184
!
claus
parents: 118
diff changeset
   185
claus
parents: 118
diff changeset
   186
examples 
claus
parents: 118
diff changeset
   187
"
122
claus
parents: 121
diff changeset
   188
    see more examples in EnterFieldGroup>>examples.
claus
parents: 121
diff changeset
   189
claus
parents: 121
diff changeset
   190
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   191
    Step-by-step introduction:
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   192
120
claus
parents: 118
diff changeset
   193
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   194
    basic field in some view:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   195
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   196
        |top field|
120
claus
parents: 118
diff changeset
   197
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   198
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   199
        top extent:200@100.
120
claus
parents: 118
diff changeset
   200
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   201
        field := EditField origin:0.0@0.0 in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   202
        field width:1.0.                                'let its height as-is'.
120
claus
parents: 118
diff changeset
   203
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   204
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   205
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   206
122
claus
parents: 121
diff changeset
   207
125
claus
parents: 122
diff changeset
   208
    forward input in topView to the field:
claus
parents: 122
diff changeset
   209
    (currently, the field does not know this - therefore,
claus
parents: 122
diff changeset
   210
     its been told here ... this may change)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   211
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   212
        |top field|
122
claus
parents: 121
diff changeset
   213
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   214
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   215
        top extent:200@100.
122
claus
parents: 121
diff changeset
   216
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   217
        field := EditField origin:0.0@0.0 in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   218
        field width:1.0.                                'let its height as-is'.
122
claus
parents: 121
diff changeset
   219
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   220
        top delegate:(KeyboardForwarder toView:field).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   221
        field hasKeyboardFocus:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   222
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   223
                                                                        [exEnd]
122
claus
parents: 121
diff changeset
   224
claus
parents: 121
diff changeset
   225
125
claus
parents: 122
diff changeset
   226
    to make it look better: set some inset:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   227
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   228
        |top field spacing|
120
claus
parents: 118
diff changeset
   229
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   230
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   231
        top extent:200@100.
120
claus
parents: 118
diff changeset
   232
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   233
        spacing := View viewSpacing.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   234
        field := EditField origin:(0.0 @ spacing) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   235
        field width:1.0.                                        'let its height as-is'.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   236
        field leftInset:spacing; rightInset:spacing.
120
claus
parents: 118
diff changeset
   237
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   238
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   239
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   240
122
claus
parents: 121
diff changeset
   241
120
claus
parents: 118
diff changeset
   242
    give it an initial contents:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   243
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   244
        |top field|
120
claus
parents: 118
diff changeset
   245
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   246
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   247
        top extent:200@100.
120
claus
parents: 118
diff changeset
   248
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   249
        field := EditField origin:(0.0 @ 0.0) in:top.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   250
        field width:1.0.       
120
claus
parents: 118
diff changeset
   251
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   252
        field editValue:'hello world'.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   253
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   254
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   255
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   256
122
claus
parents: 121
diff changeset
   257
125
claus
parents: 122
diff changeset
   258
    have it preselected:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   259
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   260
        |top field|
120
claus
parents: 118
diff changeset
   261
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   262
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   263
        top extent:200@100.
120
claus
parents: 118
diff changeset
   264
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   265
        field := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   266
        field width:1.0.     
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   267
        field editValue:'hello world' selected:true.
120
claus
parents: 118
diff changeset
   268
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   269
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   270
                                                                         [exEnd]
120
claus
parents: 118
diff changeset
   271
122
claus
parents: 121
diff changeset
   272
120
claus
parents: 118
diff changeset
   273
    have part of it preselected:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   274
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   275
        |top field|
120
claus
parents: 118
diff changeset
   276
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   277
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   278
        top extent:200@100.
120
claus
parents: 118
diff changeset
   279
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   280
        field := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   281
        field width:1.0.     
120
claus
parents: 118
diff changeset
   282
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   283
        field editValue:'hello world'.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   284
        field selectFromCharacterPosition:1 to:5.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   285
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   286
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   287
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   288
122
claus
parents: 121
diff changeset
   289
125
claus
parents: 122
diff changeset
   290
    set a size limit:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   291
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   292
        |top field|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   293
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   294
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   295
        top extent:200@100.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   296
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   297
        field := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   298
        field width:1.0.     
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   299
        field editValue:'hello'.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   300
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   301
        field maxChars:8.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   302
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   303
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   304
                                                                        [exEnd]
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   305
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   306
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   307
    set a size limit, initial width and stop it from scrolling
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   308
    notice: you may prefer a constant-pitch font (such as courier):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   309
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   310
        |top field|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   311
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   312
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   313
        top extent:200@100.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   314
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   315
        field := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   316
        field innerWidth:(field font widthOf:'00000000').     
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   317
        field editValue:'12345678'.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   318
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   319
        field maxChars:8.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   320
        field autoScroll:false.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   321
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   322
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   323
                                                                        [exEnd]
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   324
125
claus
parents: 122
diff changeset
   325
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   326
    enable / disable:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   327
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   328
        |top panel check field ena|
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   329
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   330
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   331
        top extent:200@100.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   332
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   333
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   334
        panel borderWidth:0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   335
        panel horizontalLayout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   336
        panel horizontalInset:View viewSpacing.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   337
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   338
        check := CheckBox label:'enable' in:panel.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   339
        check turnOn.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   340
        check action:[:onOff | onOff ifTrue:[field enable] ifFalse:[field disable]].
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   341
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   342
        panel add:(View new height:30; borderWidth:0).
125
claus
parents: 122
diff changeset
   343
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   344
        field := EditField in:panel.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   345
        field width:1.0.     
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   346
        field editValue:'hello'.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   347
        
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   348
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   349
                                                                        [exEnd]
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   350
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   351
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   352
    enable / disable using a channel:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   353
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   354
        |top panel check field ena|
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   355
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   356
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   357
        top extent:200@100.
125
claus
parents: 122
diff changeset
   358
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   359
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   360
        panel borderWidth:0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   361
        panel horizontalLayout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   362
        panel horizontalInset:View viewSpacing.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   363
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   364
        ena := true asValue.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   365
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   366
        check := CheckBox label:'enable' in:panel.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   367
        check model:ena.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   368
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   369
        panel add:(View new height:30; borderWidth:0).
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   370
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   371
        field := EditField in:panel.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   372
        field enableChannel:ena.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   373
        field width:1.0.     
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   374
        field editValue:'hello'.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   375
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   376
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   377
                                                                        [exEnd]
125
claus
parents: 122
diff changeset
   378
claus
parents: 122
diff changeset
   379
121
claus
parents: 120
diff changeset
   380
    use a converter:
125
claus
parents: 122
diff changeset
   381
      - numbers (default to 0):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   382
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   383
        |top field spacing|
121
claus
parents: 120
diff changeset
   384
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   385
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   386
        top extent:200@100.
121
claus
parents: 120
diff changeset
   387
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   388
        spacing := View viewSpacing.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   389
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   390
        field := EditField origin:0.0 @ spacing in:top.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   391
        field width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   392
        field horizontalInset:spacing.
121
claus
parents: 120
diff changeset
   393
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   394
        field converter:(PrintConverter new initForNumber).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   395
        field editValue:1234.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   396
        field acceptAction:[:value | Transcript showCR:value].
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   397
        field crAction:[field accept. top destroy].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   398
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   399
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   400
claus
parents: 120
diff changeset
   401
      - dates:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   402
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   403
        |top field spacing|
121
claus
parents: 120
diff changeset
   404
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   405
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   406
        top extent:200@100.
121
claus
parents: 120
diff changeset
   407
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   408
        spacing := View viewSpacing.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   409
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   410
        field := EditField origin:0.0 @ spacing in:top.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   411
        field width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   412
        field horizontalInset:spacing.
121
claus
parents: 120
diff changeset
   413
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   414
        field converter:(PrintConverter new initForDate).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   415
        field editValue:Date today.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   416
        field acceptAction:[:value | Transcript showCR:value class name , ' ' , value printString].
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   417
        field crAction:[field accept. top destroy].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   418
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   419
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   420
122
claus
parents: 121
diff changeset
   421
125
claus
parents: 122
diff changeset
   422
    setting immediateAccept, makes the field update with every key:
claus
parents: 122
diff changeset
   423
claus
parents: 122
diff changeset
   424
      - immediate accept numbers, defaulting to nil:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   425
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   426
        |top field spacing|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   427
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   428
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   429
        top extent:200@100.
121
claus
parents: 120
diff changeset
   430
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   431
        spacing := View viewSpacing.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   432
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   433
        field := EditField origin:0.0 @ spacing in:top.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   434
        field width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   435
        field horizontalInset:spacing.
121
claus
parents: 120
diff changeset
   436
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   437
        field converter:(PrintConverter new initForNumberOrNil).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   438
        field immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   439
        field editValue:1234.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   440
        field acceptAction:[:value | Transcript showCR:value].
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   441
        field crAction:[field accept. top destroy].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   442
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   443
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   444
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   445
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   446
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   447
    grouping multiple fields, and forward keyPres from the outer view to the active field
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   448
    (i.e. actually: to the group):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   449
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   450
        |top field1 field2 field3 group|
121
claus
parents: 120
diff changeset
   451
122
claus
parents: 121
diff changeset
   452
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   453
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   454
        top extent:200@100.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   455
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   456
        field1 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   457
        field1 width:1.0.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   458
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   459
        field2 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   460
        field2 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   461
        field2 topInset:(field1 height); bottomInset:(field1 height negated).
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   462
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   463
        field3 := EditField origin:(0.5 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   464
        field3 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   465
        field3 topInset:(field1 height); bottomInset:(field1 height negated).
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   466
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   467
        group := EnterFieldGroup new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   468
        group add:field1; add:field2; add:field3.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   469
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   470
        top delegate:(KeyboardForwarder to:group).
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   471
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   472
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   473
                                                                        [exEnd]
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   474
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   475
        
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   476
    in addition: tell the group to close when the last field is left:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   477
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   478
        |top field1 field2 field3 group|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   479
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   480
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   481
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   482
        top extent:200@100.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   483
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   484
        field1 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   485
        field1 width:1.0.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   486
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   487
        field2 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   488
        field2 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   489
        field2 topInset:(field1 height); bottomInset:(field1 height negated).
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   490
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   491
        field3 := EditField origin:(0.5 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   492
        field3 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   493
        field3 topInset:(field1 height); bottomInset:(field1 height negated).
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   494
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   495
        group := EnterFieldGroup new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   496
        group add:field1; add:field2; add:field3.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   497
        group leaveAction:[top destroy].
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   498
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   499
        top delegate:(KeyboardForwarder to:group).
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   500
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   501
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   502
                                                                        [exEnd]
127
claus
parents: 125
diff changeset
   503
claus
parents: 125
diff changeset
   504
120
claus
parents: 118
diff changeset
   505
    use a model:
claus
parents: 118
diff changeset
   506
    (see changing model value in inspector when return is pressed in the field)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   507
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   508
        |top field model|
120
claus
parents: 118
diff changeset
   509
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   510
        model := 'hello world' asValue.
120
claus
parents: 118
diff changeset
   511
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   512
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   513
        top extent:200@100.
120
claus
parents: 118
diff changeset
   514
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   515
        field := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   516
        field width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   517
        field model:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   518
        field acceptOnReturn:true.
120
claus
parents: 118
diff changeset
   519
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   520
        top open.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   521
        model inspect.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   522
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   523
122
claus
parents: 121
diff changeset
   524
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   525
    like above, but also accept the value, when the focus is changed
894
210626ca9586 example
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   526
    (i.e. out of the input field):
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   527
    (see changing model value in inspector)
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   528
                                                                        [exBegin]
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   529
        |top field model|
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   530
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   531
        model := 'hello world' asValue.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   532
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   533
        top := StandardSystemView new.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   534
        top extent:200@100.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   535
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   536
        field := EditField origin:(0.0 @ 0.0) in:top.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   537
        field width:1.0.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   538
        field model:model.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   539
        field acceptOnLostFocus:true.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   540
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   541
        top open.
894
210626ca9586 example
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   542
        InspectorView openOn:model monitor:'value'.
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   543
                                                                        [exEnd]
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   544
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   545
127
claus
parents: 125
diff changeset
   546
    two views on the same model (each accepts on return):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   547
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   548
        |top1 top2 field1 field2 model|
121
claus
parents: 120
diff changeset
   549
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   550
        model := 'hello world' asValue.
121
claus
parents: 120
diff changeset
   551
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   552
        top1 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   553
        top1 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   554
        field1 := EditField origin:(0.0 @ 0.0) in:top1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   555
        field1 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   556
        field1 model:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   557
        field1 acceptOnReturn:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   558
        top1 open.
121
claus
parents: 120
diff changeset
   559
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   560
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   561
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   562
        field2 := EditField origin:(0.0 @ 0.0) in:top2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   563
        field2 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   564
        field2 model:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   565
        field2 acceptOnReturn:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   566
        top2 open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   567
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   568
127
claus
parents: 125
diff changeset
   569
    two views on the same model (no accept on return):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   570
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   571
        |top1 top2 field1 field2 model|
127
claus
parents: 125
diff changeset
   572
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   573
        model := 'hello world' asValue.
127
claus
parents: 125
diff changeset
   574
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   575
        top1 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   576
        top1 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   577
        field1 := EditField origin:(0.0 @ 0.0) in:top1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   578
        field1 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   579
        field1 model:model; acceptOnReturn:false.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   580
        top1 open.
127
claus
parents: 125
diff changeset
   581
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   582
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   583
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   584
        field2 := EditField origin:(0.0 @ 0.0) in:top2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   585
        field2 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   586
        field2 model:model; acceptOnReturn:false.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   587
        top2 open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   588
                                                                        [exEnd]
127
claus
parents: 125
diff changeset
   589
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   590
    with immediate accept (every key updates the model):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   591
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   592
        |top1 top2 field1 field2 model|
125
claus
parents: 122
diff changeset
   593
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   594
        model := 'hello world' asValue.
125
claus
parents: 122
diff changeset
   595
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   596
        top1 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   597
        top1 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   598
        field1 := EditField origin:(0.0 @ 0.0) in:top1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   599
        field1 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   600
        field1 model:model; immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   601
        top1 open.
125
claus
parents: 122
diff changeset
   602
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   603
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   604
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   605
        field2 := EditField origin:(0.0 @ 0.0) in:top2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   606
        field2 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   607
        field2 model:model; immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   608
        top2 open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   609
                                                                        [exEnd]
122
claus
parents: 121
diff changeset
   610
121
claus
parents: 120
diff changeset
   611
    just an example; a checkBox and an editField on the same model:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   612
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   613
        |top1 top2 field1 box model|
121
claus
parents: 120
diff changeset
   614
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   615
        model := false asValue.
121
claus
parents: 120
diff changeset
   616
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   617
        top1 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   618
        top1 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   619
        field1 := EditField origin:(0.0 @ 0.0) in:top1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   620
        field1 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   621
        field1 converter:(PrintConverter new initForYesNo).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   622
        field1 model:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   623
        top1 open.
121
claus
parents: 120
diff changeset
   624
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   625
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   626
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   627
        box := CheckBox on:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   628
        box label:'on/off'.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   629
        top2 add:box.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   630
        top2 open.
121
claus
parents: 120
diff changeset
   631
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   632
        model inspect.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   633
                                                                        [exEnd]
125
claus
parents: 122
diff changeset
   634
claus
parents: 122
diff changeset
   635
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   636
    multiple editFields on multiple models (value holders):
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   637
    (the fields are connected by a group to allow tabbing)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   638
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   639
        |top panel group field1 field2 field3 box 
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   640
         v1 v2 v3 spacing|
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   641
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   642
        v1 := true asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   643
        v2 := 'some string' asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   644
        v3 := 1.2 asValue.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   645
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   646
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   647
        top extent:200@100.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   648
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   649
        panel := VerticalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   650
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   651
        spacing := View viewSpacing.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   652
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   653
        field1 := EditField new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   654
        field1 width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   655
        field1 horizontalInset:spacing.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   656
        field1 converter:(PrintConverter new initForYesNo).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   657
        field1 model:v1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   658
        panel add:field1.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   659
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   660
        field2 := EditField new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   661
        field2 width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   662
        field2 horizontalInset:spacing.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   663
        field2 model:v2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   664
        panel add:field2.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   665
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   666
        field3 := EditField new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   667
        field3 width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   668
        field3 horizontalInset:spacing.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   669
        field3 converter:(PrintConverter new initForNumber).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   670
        field3 model:v3.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   671
        panel add:field3.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   672
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   673
        group := EnterFieldGroup new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   674
        group add:field1; add:field2; add:field3.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   675
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   676
        top openModal.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   677
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   678
        Transcript showCR:v1 value.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   679
        Transcript showCR:v2 value.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   680
        Transcript showCR:v3 value.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   681
                                                                        [exEnd]
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   682
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   683
125
claus
parents: 122
diff changeset
   684
    connecting fields:
claus
parents: 122
diff changeset
   685
    update field2 wehenever field1 is changed.
claus
parents: 122
diff changeset
   686
    (normally, the processing below (xChanged) is done in your application
claus
parents: 122
diff changeset
   687
     class, or in a complex model. For the demonstration below, we use
claus
parents: 122
diff changeset
   688
     a Plug to simulate the protocol.)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   689
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   690
        |application top field1 field2 value1 value2|
125
claus
parents: 122
diff changeset
   691
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   692
        application := Plug new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   693
        application respondTo:#value1Changed
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   694
                         with:[value2 value:(value1 value isNil ifTrue:[nil]
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   695
                                                                ifFalse:[value1 value squared])].
125
claus
parents: 122
diff changeset
   696
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   697
        value1 := 1 asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   698
        value2 := 1 asValue.
125
claus
parents: 122
diff changeset
   699
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   700
        top := Dialog new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   701
        top extent:200@200.
125
claus
parents: 122
diff changeset
   702
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   703
        (top addTextLabel:'some number:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   704
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   705
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   706
        (top addInputFieldOn:value1 tabable:false) 
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   707
            converter:(PrintConverter new initForNumberOrNil);
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   708
            immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   709
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   710
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   711
        (top addTextLabel:'squared:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   712
        top addVerticalSpace.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   713
        (top addInputFieldOn:value2 tabable:false) 
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   714
            converter:(PrintConverter new initForNumberOrNil).
125
claus
parents: 122
diff changeset
   715
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   716
        value1 onChangeSend:#value1Changed to:application.
125
claus
parents: 122
diff changeset
   717
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   718
        top openModeless.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   719
                                                                        [exEnd]
125
claus
parents: 122
diff changeset
   720
claus
parents: 122
diff changeset
   721
claus
parents: 122
diff changeset
   722
    two-way connect:
claus
parents: 122
diff changeset
   723
    each field updates the other (notice, that we have to turn off
claus
parents: 122
diff changeset
   724
    onChange: notification, to avoid an endless notification cycle)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   725
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   726
        |application top field1 field2 value1 value2|
125
claus
parents: 122
diff changeset
   727
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   728
        application := Plug new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   729
        application respondTo:#value1Changed
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   730
                         with:[value2 retractInterestsFor:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   731
                               value2 value:(value1 value isNil ifTrue:[nil]
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   732
                                                                ifFalse:[value1 value squared]).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   733
                               value2 onChangeSend:#value2Changed to:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   734
                              ].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   735
        application respondTo:#value2Changed
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   736
                         with:[value1 retractInterestsFor:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   737
                               value1 value:(value2 value isNil ifTrue:[nil]
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   738
                                                                ifFalse:[value2 value sqrt]).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   739
                               value1 onChangeSend:#value1Changed to:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   740
                              ].
125
claus
parents: 122
diff changeset
   741
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   742
        value1 := 1 asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   743
        value2 := 1 asValue.
125
claus
parents: 122
diff changeset
   744
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   745
        top := Dialog new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   746
        top extent:200@200.
125
claus
parents: 122
diff changeset
   747
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   748
        (top addTextLabel:'some number:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   749
        top addVerticalSpace.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   750
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   751
        (top addInputFieldOn:value1 tabable:false) 
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   752
            converter:(PrintConverter new initForNumberOrNil);
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   753
            immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   754
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   755
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   756
        (top addTextLabel:'squared:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   757
        top addVerticalSpace.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   758
        (top addInputFieldOn:value2 tabable:false) 
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   759
            converter:(PrintConverter new initForNumberOrNil);
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   760
            immediateAccept:true.
125
claus
parents: 122
diff changeset
   761
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   762
        value1 onChangeSend:#value1Changed to:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   763
        value2 onChangeSend:#value2Changed to:application.
125
claus
parents: 122
diff changeset
   764
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   765
        top openModeless.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   766
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   767
"
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
   768
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   769
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   770
!EditField class methodsFor:'defaults'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   771
125
claus
parents: 122
diff changeset
   772
defaultLeaveKeys
128
claus
parents: 127
diff changeset
   773
    "return the set of keys which are taken as leave-keys.
claus
parents: 127
diff changeset
   774
     If the field is in an enterFieldGroup, all leave keys will be
claus
parents: 127
diff changeset
   775
     forwarded to the group and possible step to the next/previous field.
claus
parents: 127
diff changeset
   776
     Also, if acceptOnLeave is true, leave keys will store the current
claus
parents: 127
diff changeset
   777
     value into their model (if any)"
claus
parents: 127
diff changeset
   778
125
claus
parents: 122
diff changeset
   779
    ^ #(Return CursorUp CursorDown Next Previous Accept)
claus
parents: 122
diff changeset
   780
!
claus
parents: 122
diff changeset
   781
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   782
defaultNumberOfLines
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   783
    "the number of lines in the field"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   784
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   785
    ^ 1
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   786
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   787
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   788
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   789
    "extract values from the styleSheet and cache them in class variables"
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   790
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   791
    <resource: #style (#'editField.foregroundColor' #'editField.backgroundColor'
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   792
                       #'editField.selectionForegroundColor' #'editFieldSelectionBackgroundColor'
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   793
                       #'editField.font')>
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   794
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   795
    DefaultForegroundColor := StyleSheet colorAt:'editField.foregroundColor' default:Black.
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   796
    DefaultBackgroundColor := StyleSheet colorAt:'editField.backgroundColor' default:White.
1834
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   797
    DefaultSelectionForegroundColor := StyleSheet colorAt:'editField.selectionForegroundColor' default:nil.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   798
    DefaultSelectionForegroundColor isNil ifTrue:[
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   799
        DefaultSelectionForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor' default:DefaultBackgroundColor.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   800
    ].
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   801
    DefaultSelectionBackgroundColor := StyleSheet colorAt:'editField.selectionBackgroundColor' default:nil.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   802
    DefaultSelectionBackgroundColor isNil ifTrue:[
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   803
        DefaultSelectionBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor' default:DefaultForegroundColor.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   804
    ].
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   805
    DefaultFont := StyleSheet fontAt:'editField.font' default:nil.
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   806
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   807
    "
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   808
     self updateStyleCache
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   809
    "
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   810
1834
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   811
    "Modified: / 31.3.1999 / 00:03:12 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   812
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   813
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   814
!EditField methodsFor:'accepting'!
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   815
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   816
accept
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   817
    ""
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   818
    |val string|
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   819
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   820
    acceptEnabled == false ifTrue:[
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   821
        device beep.
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   822
        ^ self
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   823
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   824
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   825
    super accept.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   826
    converter notNil ifTrue:[
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   827
        val := self editValue.
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   828
        string := converter printStringFor:val.
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   829
        string ~= self contents ifTrue:[
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   830
            self contents:string.
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   831
            self flash
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   832
        ]
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   833
    ].
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   834
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   835
    "Modified: 7.3.1997 / 11:06:00 / cg"
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   836
! !
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   837
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   838
!EditField methodsFor:'accessing-behavior'!
125
claus
parents: 122
diff changeset
   839
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   840
acceptOnLeave:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   841
    "set/clear the acceptOnLeave flag. The default is false.
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   842
     If true, leaving the box (via return, cursor etc.) accepts my 
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   843
     string into the valueHolder (if any).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   844
     (actually, the set of keys can be specified with #leaveKeys:)"
125
claus
parents: 122
diff changeset
   845
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   846
     acceptOnLeave := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   847
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   848
    "Modified: 11.12.1996 / 16:47:25 / cg"
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   849
!
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   850
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   851
acceptOnLostFocus:aBoolean
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   852
    "set/clear the acceptOnLostFocus flag. The default is false.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   853
     If true, a lost focus (via mouse-pointer motion etc.) accepts my 
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   854
     string into the valueHolder (if any)."
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   855
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   856
     acceptOnLostFocus := aBoolean
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   857
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   858
    "Modified: 16.12.1995 / 16:26:45 / cg"
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   859
    "Created: 11.12.1996 / 16:48:00 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   860
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   861
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   862
acceptOnReturn:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   863
    "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
   864
     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
   865
     string into the valueHolder (if any)."
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   866
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   867
     acceptOnReturn := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   868
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   869
    "Modified: 16.12.1995 / 16:25:34 / cg"
125
claus
parents: 122
diff changeset
   870
!
claus
parents: 122
diff changeset
   871
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   872
acceptOnTab:aBoolean
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   873
    "set/clear the acceptOnTab flag. The default is true.
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   874
     If true, a pressed Tab key accepts and leaves the box.
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   875
     If false, the Tab key is treated like any normal input character
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   876
     (i.e. inserted into the contents)."
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   877
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   878
     acceptOnTab := aBoolean
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   879
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   880
    "Created: 24.1.1996 / 13:13:37 / cg"
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   881
!
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   882
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   883
autoScroll:aBoolean
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   884
    "turn on/off automatic scrolling upon keyboard entry
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   885
     to make the cursor visible."
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   886
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   887
    autoScrollHorizontally := aBoolean
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   888
!
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   889
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   890
clickAction:aBlock
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   891
    "define an action to be evaluated when being clicked upon"
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   892
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   893
    clickAction := aBlock
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   894
!
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   895
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   896
crAction:aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   897
    "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
   898
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   899
    crAction := aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   900
!
125
claus
parents: 122
diff changeset
   901
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   902
cursorMovementWhenUpdating:aSymbol
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   903
    "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
   904
     my contents from the model. Allowed arguments are:
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   905
	#keep / nil     -> stay where it was
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   906
	#endOfLine      -> position cursor after the string
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   907
	#beginOfLine    -> position cursor to the beginning
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   908
     The default is #endOfLine.
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   909
     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
   910
     the program (i.e. not from the user)"
125
claus
parents: 122
diff changeset
   911
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   912
    cursorMovementWhenUpdating := aSymbol
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   913
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   914
    "Modified: 16.12.1995 / 16:27:55 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   915
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   916
1034
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
   917
enabled
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
   918
    "return true, if the field is enabled (i.e. accepts keyboard input)"
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
   919
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
   920
    ^ enabled ? true 
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
   921
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
   922
!
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
   923
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   924
enabled:aBoolean
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   925
    "enable/disable the field; show/hide the cursor and allow/disallow input"
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   926
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   927
    enabled ~~ aBoolean ifTrue:[
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   928
        enabled := aBoolean.
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   929
        self updateBackground.
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   930
        super cursorShown:aBoolean
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   931
    ]
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   932
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   933
    "Modified: / 3.8.1998 / 17:52:18 / cg"
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   934
    "Created: / 30.3.1999 / 15:19:17 / stefan"
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   935
    "Modified: / 30.3.1999 / 16:00:43 / stefan"
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   936
!
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
   937
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   938
entryCompletionBlock:aOneArgBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   939
    "define an action to be evaluated when Tab (NameCompletion) is pressed.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   940
     The block gets the current contents as argument."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   941
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   942
    entryCompletionBlock := aOneArgBlock
125
claus
parents: 122
diff changeset
   943
!
claus
parents: 122
diff changeset
   944
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   945
immediateAccept:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   946
    "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
   947
     If true, every pressed key immediately accepts my 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   948
     string into the valueHolder (if any)."
155
claus
parents: 144
diff changeset
   949
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   950
     immediateAccept := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   951
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   952
    "Modified: 16.12.1995 / 16:25:57 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   953
!
155
claus
parents: 144
diff changeset
   954
995
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   955
isAcceptOnLeave
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   956
    "return the acceptOnLeave flag. The default is false.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   957
     If true, leaving the box (via return, cursor etc.) accepts my 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   958
     string into the valueHolder (if any).
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   959
     (actually, the set of keys can be specified with #leaveKeys:)"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   960
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   961
     ^ acceptOnLeave 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   962
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   963
    "Modified: 11.12.1996 / 16:47:25 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   964
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   965
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   966
isAcceptOnLostFocus
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   967
    "return the acceptOnLostFocus flag. The default is false.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   968
     If true, a lost focus (via mouse-pointer motion etc.) accepts my 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   969
     string into the valueHolder (if any)."
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   970
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   971
     ^ acceptOnLostFocus
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   972
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   973
    "Modified: 16.12.1995 / 16:26:45 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   974
    "Created: 11.12.1996 / 16:48:00 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   975
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   976
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   977
isAcceptOnReturn
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   978
    "return the acceptOnReturn flag. The default is false.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   979
     If true, leaving the box via return accepts my 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   980
     string into the valueHolder (if any)."
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   981
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   982
     ^ acceptOnReturn 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   983
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   984
    "Modified: 16.12.1995 / 16:25:34 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   985
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   986
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   987
isAcceptOnTab
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   988
    "return the acceptOnTab flag. The default is true.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   989
     If true, a pressed Tab key accepts and leaves the box.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   990
     If false, the Tab key is treated like any normal input character
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   991
     (i.e. inserted into the contents)."
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   992
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   993
     ^ acceptOnTab
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   994
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
   995
994
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
   996
isImmediateAccept
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
   997
    "return the immediateAccept flag. The default is false.
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
   998
     If true, every pressed key immediately accepts my 
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
   999
     string into the valueHolder (if any)."
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1000
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1001
     ^ immediateAccept
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1002
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1003
    "Modified: 16.12.1995 / 16:25:57 / cg"
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1004
!
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1005
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1006
leaveAction:aBlock
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1007
    "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
  1008
     (actually, the set of keys can be specified with #leaveKeys:)"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1009
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1010
    leaveAction := aBlock
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1011
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1012
    "Modified: 16.12.1995 / 16:26:36 / cg"
155
claus
parents: 144
diff changeset
  1013
!
claus
parents: 144
diff changeset
  1014
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1015
leaveKeys:aCollectionOfKeySymbols 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1016
    "define the set of keys which are interpreted as leaveKeys.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1017
     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
  1018
     The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return."
155
claus
parents: 144
diff changeset
  1019
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1020
    leaveKeys := aCollectionOfKeySymbols
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1021
!
155
claus
parents: 144
diff changeset
  1022
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1023
makeTabable
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1024
    "arrange for Tab to accept & leave the field
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1025
     If the field is part of a group, the next field gets the
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1026
     input focus"
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1027
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1028
    leaveKeys isNil ifTrue:[
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1029
        leaveKeys := self class defaultLeaveKeys
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1030
    ].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1031
    leaveKeys := leaveKeys copyWith:#Tab
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1032
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1033
    "Created: 27.4.1996 / 17:09:48 / cg"
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1034
!
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1035
1609
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1036
readOnly:aBoolean
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1037
    "make the text readonly or writable"
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1038
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1039
    super readOnly:aBoolean.
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1040
    self updateBackground.
1609
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1041
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1042
    "Created: / 26.7.1998 / 21:23:17 / cg"
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1043
    "Modified: / 3.8.1998 / 17:52:38 / cg"
1609
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1044
!
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1045
1842
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1046
returnKeyIsFocusNext
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1047
    "arrange for the return key to act as a focus-next key"
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1048
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1049
    leaveKeys := leaveKeys copy asOrderedCollection. 
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1050
    leaveKeys remove:#Return ifAbsent:nil
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1051
!
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1052
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1053
tabAction:aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1054
    "define an action to be evaluated when the tabulator key is pressed."
155
claus
parents: 144
diff changeset
  1055
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1056
    tabAction := aBlock
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1057
!
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1058
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1059
tabKey:aKeySymbol 
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1060
    "arrange for aKeySymbol to accept & leave the field
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1061
     If the field is part of a group, the next field gets the
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1062
     input focus"
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1063
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1064
    leaveKeys isNil ifTrue:[
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1065
        leaveKeys := self class defaultLeaveKeys
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1066
    ].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1067
    leaveKeys := leaveKeys copyWith:#Tab
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1068
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1069
    "Created: 27.4.1996 / 17:08:54 / cg"
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1070
! !
125
claus
parents: 122
diff changeset
  1071
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1072
!EditField methodsFor:'accessing-contents'!
125
claus
parents: 122
diff changeset
  1073
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1074
contents
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1075
    "return contents as a string
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1076
     - redefined since EditFields hold only one line of text.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1077
    In your application, please use #editValue; 
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1078
    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
  1079
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1080
    list isNil ifTrue:[^ ''].
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1081
    (list size == 0) ifTrue:[^ ''].
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1082
    ^ list at:1
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1083
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1084
125
claus
parents: 122
diff changeset
  1085
contents:someText
claus
parents: 122
diff changeset
  1086
    "set the contents from a string
claus
parents: 122
diff changeset
  1087
     - redefined to place the cursor to the end.
claus
parents: 122
diff changeset
  1088
    In your application, please use #editValue:; 
claus
parents: 122
diff changeset
  1089
    it uses a converter (if any) and is compatible to ST-80."
claus
parents: 122
diff changeset
  1090
1180
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1091
    |newCol txt|
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1092
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1093
    newCol := cursorCol.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1094
1248
d95d72a33e16 checkin from browser
ca
parents: 1225
diff changeset
  1095
    (someText respondsTo:#asString) ifTrue:[
1180
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1096
        txt := someText asString
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1097
    ].
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1098
    super contents:txt.
125
claus
parents: 122
diff changeset
  1099
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1100
    cursorMovementWhenUpdating == #endOfLine ifTrue:[
1180
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1101
         newCol := (txt size + 1).
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1102
    ] ifFalse:[
1179
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1103
        cursorMovementWhenUpdating == #beginOfLine ifTrue:[
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1104
            newCol := 1
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1105
        ] ifFalse:[
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1106
            "/ default: stay where it was
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1107
        ]
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1108
    ].
125
claus
parents: 122
diff changeset
  1109
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1110
    self cursorCol:newCol.
1179
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1111
1180
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1112
    "Modified: 4.4.1997 / 21:38:24 / cg"
125
claus
parents: 122
diff changeset
  1113
!
claus
parents: 122
diff changeset
  1114
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1115
converter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1116
    "return the converter (if any)."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1117
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1118
    ^ converter
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
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1121
converter:aConverter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1122
    "set the converter. If non-nil,
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1123
     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
  1124
     representation to the actual object value and vice versa.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1125
     The default converter is nil, meaning no-conversion
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1126
     (i.e. the edited object is the string itself."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1127
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1128
    converter := aConverter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1129
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1130
125
claus
parents: 122
diff changeset
  1131
editValue
claus
parents: 122
diff changeset
  1132
    "if the field edits a string, this is a name alias for #contents.
claus
parents: 122
diff changeset
  1133
     Otherwise, if there is a converter, return the edited string
claus
parents: 122
diff changeset
  1134
     converted to an appropriate object."
claus
parents: 122
diff changeset
  1135
claus
parents: 122
diff changeset
  1136
    |string|
claus
parents: 122
diff changeset
  1137
claus
parents: 122
diff changeset
  1138
    string := self contents.
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1139
    string isNil ifTrue:[string := ''].
125
claus
parents: 122
diff changeset
  1140
    converter isNil ifTrue:[^ string].
claus
parents: 122
diff changeset
  1141
    ^ converter readValueFrom:string 
claus
parents: 122
diff changeset
  1142
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1143
125
claus
parents: 122
diff changeset
  1144
editValue:aStringOrObject
claus
parents: 122
diff changeset
  1145
    "set the contents. If there is a converter, use it to convert
claus
parents: 122
diff changeset
  1146
     the object into a printed representation.
claus
parents: 122
diff changeset
  1147
     Otherwise, the argument is supposed to be a string like object,
claus
parents: 122
diff changeset
  1148
     and used directly (i.e. this is equivalent to sending #contents:)."
claus
parents: 122
diff changeset
  1149
claus
parents: 122
diff changeset
  1150
    self editValue:aStringOrObject selected:false
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1151
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1152
125
claus
parents: 122
diff changeset
  1153
editValue:aStringOrObject selected:aBoolean
claus
parents: 122
diff changeset
  1154
    "set the contents. If there is a converter, use it to convert
claus
parents: 122
diff changeset
  1155
     the object into a printed representation.
claus
parents: 122
diff changeset
  1156
     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
  1157
     and used directly (i.e. this is equivalent to sending #initialText:selected:)."
125
claus
parents: 122
diff changeset
  1158
claus
parents: 122
diff changeset
  1159
    |string|
claus
parents: 122
diff changeset
  1160
claus
parents: 122
diff changeset
  1161
    converter notNil ifTrue:[
claus
parents: 122
diff changeset
  1162
	string := converter printStringFor:aStringOrObject
claus
parents: 122
diff changeset
  1163
    ] ifFalse:[
claus
parents: 122
diff changeset
  1164
	string :=  aStringOrObject.
claus
parents: 122
diff changeset
  1165
    ].
claus
parents: 122
diff changeset
  1166
    self contents:string.
claus
parents: 122
diff changeset
  1167
    aBoolean ifTrue:[
claus
parents: 122
diff changeset
  1168
	self selectFromLine:1 col:1 toLine:1 col:string size
claus
parents: 122
diff changeset
  1169
    ]
claus
parents: 122
diff changeset
  1170
!
claus
parents: 122
diff changeset
  1171
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1172
initialText:aString
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1173
    "set the initialText and select it"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1174
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1175
    self initialText:aString selected:true
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1176
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1177
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1178
initialText:aString selected:aBoolean
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1179
    "set the initialText and select it if aBoolean is true"
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1180
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1181
    |len s|
125
claus
parents: 122
diff changeset
  1182
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1183
    leftOffset := 0.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1184
    (s := aString) notNil ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1185
	s := s asString
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1186
    ].
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1187
    self contents:s.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1188
    aBoolean ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1189
	(len := s size) ~~ 0 ifTrue:[
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1190
	    self selectFromLine:1 col:1 toLine:1 col:len
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1191
	]
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1192
    ]
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1193
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1194
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1195
list:someText
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1196
    "low level access to the underlying contents' list.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1197
     Redefined to force text to 1 line, and notify dependents
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1198
     of any changed extent-wishes (for automatic box resizing)."
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
    |l oldWidth|
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1201
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1202
    l := someText.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1203
    l size > 1 ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1204
        l := OrderedCollection with:(l at:1)
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1205
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1206
    oldWidth := self widthOfContents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1207
    super list:l.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1208
    self widthOfContents ~~ oldWidth ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1209
        self changedPreferredBounds:nil
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1210
    ]
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1211
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1212
    "Modified: 6.3.1997 / 16:13:36 / cg"
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1213
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1214
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1215
stringValue
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1216
    "alias for #contents - for compatibility with ST-80's InputField"
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1217
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1218
    ^ self contents
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1219
! !
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1220
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1221
!EditField methodsFor:'accessing-look'!
125
claus
parents: 122
diff changeset
  1222
155
claus
parents: 144
diff changeset
  1223
maxChars
claus
parents: 144
diff changeset
  1224
    "return the maximum number of characters that are allowed in
claus
parents: 144
diff changeset
  1225
     the field. 
claus
parents: 144
diff changeset
  1226
     A limit of nil means: unlimited. This is the default."
claus
parents: 144
diff changeset
  1227
claus
parents: 144
diff changeset
  1228
    ^ lengthLimit
claus
parents: 144
diff changeset
  1229
claus
parents: 144
diff changeset
  1230
    "Modified: 6.9.1995 / 13:43:33 / claus"
claus
parents: 144
diff changeset
  1231
!
claus
parents: 144
diff changeset
  1232
125
claus
parents: 122
diff changeset
  1233
maxChars:aNumberOrNil
claus
parents: 122
diff changeset
  1234
    "set the maximum number of characters that are allowed in
claus
parents: 122
diff changeset
  1235
     the field. Additional input will be ignored by the field.
1034
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1236
     A limit of nil or zero means: unlimited. This is the default.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1237
     If set, a lengthLimit must be defined before any contents is placed
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1238
     into the field, because the contents is not cut when the max is
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1239
     changed later. I.e. it should be set early after creation of the field.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1240
125
claus
parents: 122
diff changeset
  1241
     This method has been renamed from #lengthLimit: for ST-80
claus
parents: 122
diff changeset
  1242
     compatibility."
claus
parents: 122
diff changeset
  1243
1034
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1244
    aNumberOrNil == 0 ifTrue:[
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1245
        lengthLimit := nil
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1246
    ] ifFalse:[
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1247
        lengthLimit := aNumberOrNil.
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1248
    ]
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1249
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1250
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1251
passwordCharacter
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1252
    "return the passwordCharacter;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1253
     If nonNil, that one is replacing typed input
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1254
     (for secret input)"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1255
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1256
    ^ passwordCharacter
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1257
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1258
    "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
  1259
    "Modified: 16.12.1995 / 16:24:25 / cg"
125
claus
parents: 122
diff changeset
  1260
!
claus
parents: 122
diff changeset
  1261
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1262
passwordCharacter:aCharacter
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1263
    "set the passwordCharacter;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1264
     If nonNil, that one is replacing typed input
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1265
     (for secret input)"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1266
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1267
    passwordCharacter := aCharacter
97
cbf495fe3b64 *** empty log message ***
claus
parents: 77
diff changeset
  1268
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1269
    "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
  1270
    "Modified: 16.12.1995 / 16:24:33 / cg"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
  1271
! !
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
  1272
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1273
!EditField methodsFor:'cursor drawing'!
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1274
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1275
cursorShown:aBoolean
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1276
    "make cursor visible if currently invisible - but only if this
1880
3ad00c12541e comment
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1277
     EditField is enabled. 
3ad00c12541e comment
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1278
     Return the previous cursor-shown-state"
1399
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1279
1836
97361bf30af6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1834
diff changeset
  1280
    ^ super cursorShown:(aBoolean and:[enabled and:[self isReadOnly not]])
1399
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1281
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1282
    "Created: / 30.3.1999 / 16:00:25 / stefan"
1880
3ad00c12541e comment
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1283
    "Modified: / 1.4.1999 / 11:18:38 / cg"
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1284
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1285
155
claus
parents: 144
diff changeset
  1286
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
claus
parents: 144
diff changeset
  1287
    startVisLineNr to:endVisLineNr do:[:visLine |
claus
parents: 144
diff changeset
  1288
	self drawVisibleLine:visLine with:fg and:bg
claus
parents: 144
diff changeset
  1289
    ]
claus
parents: 144
diff changeset
  1290
claus
parents: 144
diff changeset
  1291
    "Modified: 6.9.1995 / 12:24:29 / claus"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1292
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1293
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1294
!EditField methodsFor:'cursor movement'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1295
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1296
cursorDown
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1297
    "catch cursor movement"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1298
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1299
    (cursorVisibleLine == nLinesShown) ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
  1300
	super cursorDown
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1301
    ]
192
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
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1304
cursorLine:line col:col
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1305
    "catch cursor movement"
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
    super cursorLine:1 col:col
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1308
!
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1309
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1310
validateCursorCol:col inLine:line
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1311
    "check of col is a valid cursor position;
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1312
     return a fixed value if not."
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1313
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1314
    |sz|
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1315
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1316
    sz := self contents size.
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1317
    lengthLimit notNil ifTrue:[
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1318
        sz := sz min:lengthLimit.
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1319
    ].
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1320
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1321
    col <= sz ifTrue:[
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1322
        ^ col
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1323
    ].
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1324
    ^ sz + 1.  "/ to allow positioning right behind the string
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1325
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1326
    "Created: 22.5.1996 / 18:17:27 / cg"
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1327
    "Modified: 22.5.1996 / 18:19:04 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1328
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1329
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1330
!EditField methodsFor:'editing'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1331
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1332
paste:someText
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1333
    "redefined to force text to 1 line"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1334
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1335
    super paste:someText.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1336
    list size > 1 ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1337
	self deleteFromLine:2 toLine:(list size)
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1338
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1339
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1340
70
14443a9ea4ec *** empty log message ***
claus
parents: 62
diff changeset
  1341
!EditField methodsFor:'event handling'!
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1342
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1343
buttonPress:button x:x y:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1344
    "enable myself on mouse click"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1345
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1346
    |prevFocus|
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1347
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1348
    enabled ifFalse:[^ self].
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1349
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1350
    prevFocus := hasKeyboardFocus.
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1351
    clickAction notNil ifTrue:[
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1352
        clickAction value:self
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1353
    ].
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1354
    hasKeyboardFocus ~~ prevFocus ifTrue:[
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1355
        ^ self
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1356
    ].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1357
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1358
    super buttonPress:button x:x y:y
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1359
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1360
"/    enabled ifFalse:[
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1361
"/        enabled := true.
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1362
"/        super buttonPress:button x:x y:y.
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1363
"/        enableAction notNil ifTrue:[
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1364
"/            enableAction value
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1365
"/        ]
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1366
"/    ] ifTrue:[
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1367
"/        super buttonPress:button x:x y:y
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1368
"/    ]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1369
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1370
    "Modified: 22.5.1996 / 15:02:45 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1371
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1372
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1373
canHandle:aKey
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1374
    "return true, if the receiver would like to handle aKey
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1375
     (usually from another view, when the receiver is part of
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1376
      a more complex dialog box).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1377
     We do return true here, since the editfield will handle
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1378
     all keys.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1379
     OBSOLETE: dont use this anymore - its a leftover for the tableWidget"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1380
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1381
    ^ true
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1382
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1383
125
claus
parents: 122
diff changeset
  1384
keyPress:key x:x y:y
claus
parents: 122
diff changeset
  1385
    "if keyHandler is defined, pass input; otherwise check for leave
claus
parents: 122
diff changeset
  1386
     keys"
claus
parents: 122
diff changeset
  1387
490
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  1388
    <resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 894
diff changeset
  1389
                          #DeleteLine #GotoLine #EndOfLine #EndOfText
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 894
diff changeset
  1390
                          #CursorDown #CursorUp)>
132
claus
parents: 131
diff changeset
  1391
1282
781c5d134e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
  1392
    |leave oldContents newContents|
125
claus
parents: 122
diff changeset
  1393
claus
parents: 122
diff changeset
  1394
    enabled ifFalse:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1395
        ^ self
125
claus
parents: 122
diff changeset
  1396
    ].
claus
parents: 122
diff changeset
  1397
claus
parents: 122
diff changeset
  1398
    (key == #DeleteLine) ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1399
        Smalltalk at:#CopyBuffer put:(self contents).
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1400
        self contents:''. ^ self
125
claus
parents: 122
diff changeset
  1401
    ].
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1402
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
  1403
    leave := leaveKeys includes:key.
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
  1404
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1405
    (key == entryCompletionCharacter
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1406
     and:[entryCompletionBlock notNil]) ifTrue:[
979
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1407
        oldContents := self contents.
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1408
        oldContents isNil ifTrue:[
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1409
            oldContents := ''
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1410
        ] ifFalse:[
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1411
            oldContents := oldContents asString
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1412
        ].
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1413
979
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1414
        entryCompletionBlock value:oldContents.
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1415
979
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1416
        newContents := self contents.
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1417
        newContents isNil ifTrue:[
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1418
            newContents := ''
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1419
        ] ifFalse:[
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1420
            newContents := newContents asString
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1421
        ].
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1422
        newContents ~= oldContents ifTrue:[
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1423
            self textChanged
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1424
        ].
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1425
        ^ self
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1426
    ].
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1427
125
claus
parents: 122
diff changeset
  1428
    (key == #Tab) ifTrue:[
964
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1429
        tabAction notNil ifTrue:[
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1430
            "/ tab-hook. 
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1431
            acceptOnTab ifTrue:[
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1432
                self accept.
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1433
            ].
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1434
            tabAction value. 
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1435
            ^ self
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1436
        ].
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1437
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1438
        acceptOnTab ifTrue:[
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1439
            self accept.
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1440
        ].
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1441
        leave ifFalse:[
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1442
            "/ forward it as a Focus-step
1842
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1443
            ^ super keyPress:(self sensor shiftDown ifTrue:[#FocusPrevious]
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1444
                                                    ifFalse:[#FocusNext])
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1445
                           x:x y:y
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1446
        ]
125
claus
parents: 122
diff changeset
  1447
    ].
480
dd6263c5f9ee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
  1448
125
claus
parents: 122
diff changeset
  1449
    (key == #Return) ifTrue:[
964
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1450
        crAction notNil ifTrue:[
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1451
            "/ cr-hook. 
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1452
            acceptOnReturn ifTrue:[
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1453
                self accept.
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1454
            ].
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1455
            crAction value.
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1456
            ^ self
73525cfd8fa2 dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1457
        ].
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1458
        leave ifFalse:[
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1459
            "/ forward it as a Focus-step
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1460
            ^ super keyPress:#FocusNext x:x y:y
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1461
        ]
125
claus
parents: 122
diff changeset
  1462
    ].
480
dd6263c5f9ee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
  1463
125
claus
parents: 122
diff changeset
  1464
    leave ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1465
        ((key == #Return and:[acceptOnReturn])
480
dd6263c5f9ee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
  1466
        or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1467
            self accept.
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1468
        ].
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1469
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1470
        leaveAction notNil ifTrue:[
1795
09b19fcb4215 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
  1471
            leaveAction numArgs == 2 ifTrue:[
09b19fcb4215 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
  1472
                ^ leaveAction value:self value:key
09b19fcb4215 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
  1473
            ].
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1474
            ^ leaveAction value:key
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1475
        ].
125
claus
parents: 122
diff changeset
  1476
611
87637cf3931b Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents: 601
diff changeset
  1477
        (x notNil and:[x >= 0]) ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1478
            "
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1479
             we do not handle this key directly.
611
87637cf3931b Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents: 601
diff changeset
  1480
             let superview know about the key that caused us to leave (maybe RETURN, DOWN, UP etc....
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1481
            "
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1482
            (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1483
                superView keyPress:key x:x y:y.
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1484
            ].
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1485
        ].
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1486
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1487
        "/ a leave, but no action defined
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1488
        "/ forward it as a Focus-step
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1489
        key == #CursorDown ifTrue:[
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1490
            "/ forward it as a Focus-step
1795
09b19fcb4215 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
  1491
            ^ self windowGroup focusNext.
09b19fcb4215 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
  1492
"/            ^ super keyPress:#FocusNext x:x y:y
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1493
        ].
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1494
        key == #CursorUp ifTrue:[
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1495
            "/ forward it as a Focus-step
1795
09b19fcb4215 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
  1496
            ^ self windowGroup focusPrevious.
09b19fcb4215 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
  1497
"/            ^ super keyPress:#FocusPrevious x:x y:y
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1498
        ].
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1499
        ^ self
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1500
    ].
121
claus
parents: 120
diff changeset
  1501
125
claus
parents: 122
diff changeset
  1502
    "
claus
parents: 122
diff changeset
  1503
     ignore some keys (if not a leaveKey) ...
claus
parents: 122
diff changeset
  1504
    "
claus
parents: 122
diff changeset
  1505
    (key == #Find) ifTrue:[^self].
claus
parents: 122
diff changeset
  1506
    (key == #FindNext) ifTrue:[^self].
claus
parents: 122
diff changeset
  1507
    (key == #FindPrev) ifTrue:[^self].
claus
parents: 122
diff changeset
  1508
    (key == #GotoLine) ifTrue:[^self].
claus
parents: 122
diff changeset
  1509
claus
parents: 122
diff changeset
  1510
    "
claus
parents: 122
diff changeset
  1511
     a normal key - let superclass's method insert it
claus
parents: 122
diff changeset
  1512
    "
claus
parents: 122
diff changeset
  1513
    super keyPress:key x:x y:y.
claus
parents: 122
diff changeset
  1514
claus
parents: 122
diff changeset
  1515
    "
claus
parents: 122
diff changeset
  1516
     for end-of-text, also move to end-of-line
claus
parents: 122
diff changeset
  1517
    "
claus
parents: 122
diff changeset
  1518
    key == #EndOfText ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1519
        super keyPress:#EndOfLine x:x y:y.
125
claus
parents: 122
diff changeset
  1520
    ].
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1521
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1522
    self resizeOrScroll.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1523
611
87637cf3931b Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents: 601
diff changeset
  1524
    "Modified: 2.5.1996 / 17:24:16 / stefan"
1061
eef045108fe0 oops - Shift-TAB is focusPrevious; not focusNext.
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  1525
    "Modified: 26.2.1997 / 00:14:06 / cg"
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1526
!
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1527
1936
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1528
pointerLeave:state
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1529
    (acceptOnLeave and:[enabled and:[self modified]]) ifTrue:[
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1530
        self accept
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1531
    ].
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1532
    super pointerLeave:state
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1533
!
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1534
1781
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1535
requestAutoAccept
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1536
    "this is invoked when a dialog closes via accept or cancel.
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1537
     This forces my value to be accepted into my model"
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1538
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1539
    acceptEnabled == false ifTrue:[
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1540
        "/ nope -
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1541
        ^ false
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1542
    ].
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1543
    self accept.
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1544
    ^ true.
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1545
!
5169563515ef added autoAccept for dialogs.
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
  1546
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1547
resizeOrScroll
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1548
    "helper for keyPress.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1549
     Extracted for easier subclass redefinition."
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1550
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1551
    |xCol newOffset newWidth|
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1552
125
claus
parents: 122
diff changeset
  1553
    newWidth := self widthOfContents.
claus
parents: 122
diff changeset
  1554
claus
parents: 122
diff changeset
  1555
    "
claus
parents: 122
diff changeset
  1556
     should (& can) we resize ?
claus
parents: 122
diff changeset
  1557
    "
claus
parents: 122
diff changeset
  1558
    xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
claus
parents: 122
diff changeset
  1559
    (xCol > (width * (5/6))) ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1560
        self changedPreferredBounds:nil
125
claus
parents: 122
diff changeset
  1561
    ] ifFalse:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1562
        newWidth < (width * (1/6)) ifTrue:[
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1563
            self changedPreferredBounds:nil
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1564
        ]
125
claus
parents: 122
diff changeset
  1565
    ].
claus
parents: 122
diff changeset
  1566
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1567
    autoScrollHorizontally ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1568
        "
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1569
         did someone react (i.e. has my extent changed) ?
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1570
         (if not, we scroll horizontally)
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1571
        "
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1572
        xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1573
        (xCol > (width * (5/6))) ifTrue:[
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1574
            newOffset := leftOffset + (width // 2).
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1575
        ] ifFalse:[
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1576
            (xCol < (width * (1/6))) ifTrue:[
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1577
                newOffset := 0 max: leftOffset - (width // 2).
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1578
            ] ifFalse:[
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1579
                newOffset := leftOffset
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1580
            ]
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1581
        ].
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1582
        newOffset ~~ leftOffset ifTrue:[
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1583
            self scrollHorizontalTo:newOffset.
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1584
        ]
125
claus
parents: 122
diff changeset
  1585
    ].
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1586
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1587
    "Modified: 6.3.1997 / 16:13:59 / cg"
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1588
!
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1589
784
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1590
sizeChanged:how
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1591
    "scroll to origin, if all fits"
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1592
1282
781c5d134e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
  1593
    |xCol|
784
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1594
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1595
    leftOffset ~~ 0 ifTrue:[
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1596
        xCol := self xOfCol:cursorCol inVisibleLine:cursorLine.
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1597
        (xCol < (width * (5/6))) ifTrue:[
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1598
            self scrollHorizontalTo:0
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1599
        ].
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1600
    ].
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1601
    self makeCursorVisible.
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1602
    super sizeChanged:how
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1603
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1604
    "Modified: 10.7.1996 / 10:59:37 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1605
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1606
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1607
!EditField methodsFor:'focus handling'!
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1608
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1609
hasKeyboardFocus:aBoolean
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1610
    "the view got/lost the keyboard focus"
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1611
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1612
    aBoolean ifFalse:[
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1613
        acceptOnLostFocus ifTrue:[
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1614
            model notNil ifTrue:[
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1615
                model value = self argForChangeMessage ifTrue:[
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1616
                    ^ self
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1617
                ]
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1618
            ].
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1619
            self accept.
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1620
        ].
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1621
    ].
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1622
    super hasKeyboardFocus:aBoolean
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1623
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1624
    "Created: / 11.12.1996 / 16:57:50 / cg"
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1625
    "Modified: / 6.12.1997 / 14:07:12 / cg"
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1626
!
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1627
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1628
showFocus:explicit
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1629
    "the view got the keyboard focus 
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1630
     (either explicit, via tabbing; or implicit, by pointer movement)
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1631
      - change any display attributes as req'd."
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1632
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1633
    "/ giving me the focus is like clicking on me
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1634
    "/ (tell my enterFieldGroup ...)
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1635
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1636
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1637
    (enabled or:[explicit]) ifTrue:[
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1638
        clickAction notNil ifTrue:[clickAction value:self].
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1639
        super showFocus:explicit
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1640
    ]
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1641
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1642
    "Modified: 9.2.1996 / 20:49:48 / cg"
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1643
!
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1644
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1645
showNoFocus:explicit
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1646
    "the view lost the keyboard focus 
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1647
     (either explicit, via tabbing; or implicit, by pointer movement)
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1648
      - change any display attributes as req'd."
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1649
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1650
    self hideCursor.
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1651
    super showNoFocus:explicit
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1652
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1653
    "Modified: / 17.9.1998 / 15:10:04 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1654
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1655
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1656
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1657
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1658
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1659
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1660
    |pref|
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1661
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1662
    pref := UserPreferences current focusFollowsMouse.
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1663
    (pref ~~ false
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1664
    and:[(styleSheet at:#'editField.requestFocusOnPointerEnter' default:true)
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1665
    and:[enabled 
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1666
    and:[readOnly not]]]) ifTrue:[
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1667
        ^ true
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1668
    ].
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1669
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1670
    ^ false
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1671
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  1672
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1673
! !
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1674
1856
f36184163cd0 category change
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
  1675
!EditField methodsFor:'initialize / release'!
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1676
1399
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1677
destroy
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1678
    enableChannel notNil ifTrue:[
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1679
        enableChannel removeDependent:self.
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1680
        enableChannel := nil.
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1681
    ].
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1682
    super destroy
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1683
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1684
    "Created: / 14.11.1997 / 13:53:50 / cg"
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1685
    "Modified: / 14.11.1997 / 13:58:49 / cg"
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1686
!
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1687
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1688
editMenu
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  1689
    "return a popUpMenu for the receiver"
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  1690
725
0509f409f9a5 added resource info
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
  1691
    <resource: #keyboard ( #Accept #Copy #Cut #Paste ) >
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1248
diff changeset
  1692
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1047
diff changeset
  1693
725
0509f409f9a5 added resource info
Claus Gittinger <cg@exept.de>
parents: 723
diff changeset
  1694
1547
57b45c785615 use new menu-creation message.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
  1695
    |items m|
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1696
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1683
diff changeset
  1697
    self isReadOnly == true ifTrue:[
1616
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1698
        items := #(
1547
57b45c785615 use new menu-creation message.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
  1699
                ('copy'   copySelection  Copy  )
1616
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1700
                )
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1701
    ] ifFalse:[
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1702
        items := #(
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1703
                    ('copy'   copySelection  Copy  )
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1704
                    ('cut'    cut            Cut   )
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1705
                    ('paste'  pasteOrReplace Paste )
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1706
                   ).
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1707
        (acceptAction notNil 
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1708
        or:[model notNil and:[changeMsg notNil]]) ifTrue:[
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1709
            immediateAccept ifFalse:[
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1710
                items := items , #(
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1711
                                        ('-'                     )
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1712
                                        ('accept'  accept  Accept)
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1713
                                    ).
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1714
            ].
677
5cacd1adea6a no <accept> menu if immediateAccept is on
Claus Gittinger <cg@exept.de>
parents: 673
diff changeset
  1715
        ].
506
3273d75c3526 added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
  1716
    ].
3273d75c3526 added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
  1717
1547
57b45c785615 use new menu-creation message.
Claus Gittinger <cg@exept.de>
parents: 1544
diff changeset
  1718
    m := PopUpMenu itemList:items resources:resources.
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1719
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1720
    self hasSelection ifFalse:[
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1721
        m disableAll:#(copySelection cut)
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1722
    ].
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1683
diff changeset
  1723
    (enabled not or:[self isReadOnly]) ifTrue:[
1616
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1724
        m disableAll:#(cut pasteOrReplace accept)
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1725
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1726
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1727
    ^ m
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1728
1616
92c7be73028f hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents: 1609
diff changeset
  1729
    "Modified: / 28.7.1998 / 11:35:41 / cg"
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1730
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1731
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1732
initStyle
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  1733
    "setup viewStyle specifics"
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  1734
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1735
    super initStyle.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1736
392
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
  1737
"/    DefaultFont notNil ifTrue:[font := DefaultFont on:device]
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
  1738
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1739
    DefaultBackgroundColor notNil ifTrue:[
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  1740
        bgColor := DefaultBackgroundColor on:device.
1482
19c10a4142bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  1741
"/        bgColor ditherForm notNil ifTrue:[
19c10a4142bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  1742
"/            bgColor := (bgColor copy) exactOrNearestOn:device
19c10a4142bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  1743
"/        ].
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  1744
        self viewBackground:bgColor.
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1745
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1746
    fgColor := DefaultForegroundColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1747
    selectionFgColor := DefaultSelectionForegroundColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1748
    selectionBgColor := DefaultSelectionBackgroundColor.
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  1749
1544
bb7e168dd651 dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1750
    "/ enable this, when the focus detection works correctly (in dialogs)
1848
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1751
    cursorTypeNoFocus := #none.
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1752
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1753
    cursorType := styleSheet at:#'editField.cursorType' default:cursorType.
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1754
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1755
    cursorFgColor := styleSheet at:#'editField.cursorForegroundColor' default:cursorFgColor.
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1756
    cursorBgColor := styleSheet at:#'editField.cursorBackgroundColor' default:cursorBgColor.
1544
bb7e168dd651 dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1757
bb7e168dd651 dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1758
    "Modified: / 21.5.1998 / 15:38:14 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1759
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1760
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1761
initialize
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1762
    super initialize.
832
4c4b0e34e964 use new #initialHeight:
dq
parents: 800
diff changeset
  1763
    self initialHeight:(font height + font descent + (topMargin * 2)).
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1764
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1765
    nFullLinesShown := 1.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1766
    nLinesShown := 1.
1225
6220d3bd3033 initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1767
    trimBlankLines := immediateAccept := acceptOnLostFocus := false.
6220d3bd3033 initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1768
    enabled := fixedSize := autoScrollHorizontally := true.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
  1769
    acceptOnLeave := acceptOnReturn := acceptOnTab := true.
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1770
    cursorShown := true.
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1771
    entryCompletionCharacter := #Tab.
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1772
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1773
    leaveKeys isNil ifTrue:[
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1774
        leaveKeys := self class defaultLeaveKeys.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1775
    ].
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1776
    cursorMovementWhenUpdating := #endOfLine
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1777
1225
6220d3bd3033 initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  1778
    "Modified: 20.5.1997 / 19:00:49 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1779
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1780
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1781
!EditField methodsFor:'private'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1782
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1783
argForChangeMessage
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1784
    "redefined to send use converted value (if I have one)"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1785
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1786
    ^ self editValue
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1787
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1788
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1789
getListFromModel
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1790
    "redefined to aquire the text via the aspectMsg - not the listMsg,
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1791
     and to ignore updates resulting from my own change."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1792
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1793
    |val|
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1794
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1795
    (model notNil and:[aspectMsg notNil]) ifTrue:[
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1796
        aspectMsg == #value ifTrue:[
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1797
            val := model value
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1798
        ] ifFalse:[
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1799
            val := model perform:aspectMsg
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1800
        ].
1503
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1801
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1802
        "
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1803
         ignore updates from my own change
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1804
        "
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1805
        lockUpdates ifTrue:[
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1806
            lockUpdates := false.
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1807
            val = self editValue ifTrue:[
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1808
                ^ self
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1809
            ]
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1810
        ].
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1811
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1812
        self editValue:val.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1813
    ]
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  1814
1503
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  1815
    "Modified: / 23.4.1998 / 10:10:37 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1816
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1817
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1818
startAutoScrollDown:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1819
    "no vertical scrolling in editfields"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1820
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1821
    ^ self
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1822
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1823
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1824
startAutoScrollUp:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1825
    "no vertical scrolling in editfields"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1826
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1827
    ^ self
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1828
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1829
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1830
textChanged
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1831
    "this is sent by mySelf (somewhere in a superclass) whenever
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1832
     my contents has changed. 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1833
     A good place to add immediateAccept functionality and check for the
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1834
     lengthLimit."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1835
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1836
    |string c|
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1837
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1838
    super textChanged.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1839
    string := self contents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1840
    lengthLimit notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1841
	string size > lengthLimit ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1842
	    c := cursorCol.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1843
	    self contents:(string copyTo:lengthLimit).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1844
	    self flash.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1845
	    self cursorCol:c.
125
claus
parents: 122
diff changeset
  1846
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1847
    ].
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1848
    immediateAccept ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1849
	self accept
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1850
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1851
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1852
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1853
updateBackground
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1854
    "make my background grey, whenever either readOnly or disable"
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1855
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1683
diff changeset
  1856
    (self isReadOnly or:[enabled not]) ifTrue:[
1632
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  1857
        self backgroundColor:(View defaultViewBackgroundColor).
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  1858
        enabled ifFalse:[
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  1859
            self foregroundColor:(StyleSheet colorAt:'button.disabledForegroundColor' default:Color gray).
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  1860
        ]
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1861
    ] ifFalse:[
1632
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  1862
        self backgroundColor:DefaultBackgroundColor.
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  1863
        self foregroundColor:DefaultForegroundColor.
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1864
    ]
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1865
1632
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  1866
    "Modified: / 3.8.1998 / 18:40:11 / cg"
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1867
!
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1868
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1869
visibleAt:visLineNr
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1870
    "return the string at lineNr for display.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1871
     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
  1872
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1873
    |s|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1874
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1875
    s := super visibleAt:visLineNr.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1876
    passwordCharacter notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1877
	^ String new:(s size) withAll:passwordCharacter
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1878
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1879
    ^ s
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1880
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1881
    "Modified: 6.9.1995 / 12:25:06 / claus"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1882
! !
125
claus
parents: 122
diff changeset
  1883
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1884
!EditField methodsFor:'queries'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1885
561
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1886
isInputField
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1887
    "return true, if the receiver is some kind of input view,
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1888
     i.e. it should (can) be part of an enterGroup.
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1889
     Return true here"
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1890
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1891
    ^ true
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1892
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1893
    "Created: 4.3.1996 / 11:32:34 / cg"
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1894
!
ef45086071c6 oops - isInputView renamed to isInputField
ca
parents: 506
diff changeset
  1895
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1896
preferredExtent
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1897
    "return the preferred extent of this view.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1898
     That is the width of the string plus some extra, 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1899
     but not wider than half of the screen"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1900
1120
3faa7fc84bad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  1901
    |string w h f|
125
claus
parents: 122
diff changeset
  1902
800
0d8a2d42398d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1903
    "/ If I have an explicit preferredExtent ..
0d8a2d42398d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1904
714
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 677
diff changeset
  1905
    preferredExtent notNil ifTrue:[
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 677
diff changeset
  1906
        ^ preferredExtent
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 677
diff changeset
  1907
    ].
5ff02d2d9fa7 care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 677
diff changeset
  1908
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1909
    string := self contents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1910
    (string isNil or:[string isBlank]) ifTrue:[
667
d02f6bba8fc5 use fonts maxHeight in prefExtent (A-Umlaut)
Claus Gittinger <cg@exept.de>
parents: 660
diff changeset
  1911
        string := '          ' "/ just any string is ok ^ super preferredExtent
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1912
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1913
    f := font on:device.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1914
    w := ((f widthOf:string) * 1.5) rounded.
1120
3faa7fc84bad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  1915
    w := w + margin + margin.
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1916
    w := w min:(device width // 2).
667
d02f6bba8fc5 use fonts maxHeight in prefExtent (A-Umlaut)
Claus Gittinger <cg@exept.de>
parents: 660
diff changeset
  1917
1542
5778dd813273 default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents: 1537
diff changeset
  1918
    h := f maxHeight + (f maxDescent * 2) + (margin * 2).
1120
3faa7fc84bad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  1919
3faa7fc84bad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  1920
    ^ w rounded @ h rounded
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1921
1542
5778dd813273 default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents: 1537
diff changeset
  1922
    "Modified: / 6.9.1995 / 19:24:06 / claus"
5778dd813273 default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents: 1537
diff changeset
  1923
    "Modified: / 21.5.1998 / 02:13:35 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1924
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1925
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1926
specClass
1372
c32cb309da8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1927
    "redefined, since the name of my specClass is nonStandard (i.e. not EditFieldSpec)"
c32cb309da8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1928
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1929
    self class == EditField ifTrue:[^ InputFieldSpec].
1047
4d7bc9784f94 specClass query
ca
parents: 1034
diff changeset
  1930
    ^ super specClass
125
claus
parents: 122
diff changeset
  1931
1372
c32cb309da8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1932
    "Modified: / 5.9.1995 / 17:28:27 / claus"
c32cb309da8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1933
    "Modified: / 31.10.1997 / 19:48:59 / cg"
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1934
!
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1935
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1936
tabMeansNextField
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1937
    "return true, if Tab character should shift focus to the next field"
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1938
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1939
    "if I have a completionBlock, I want my Tabs ..."
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1940
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1941
    ^ entryCompletionBlock isNil or:[entryCompletionCharacter ~~ #Tab]
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1942
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1943
    "Created: 7.2.1996 / 19:16:38 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1944
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1945
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1946
!EditField methodsFor:'realization'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1947
1274
a861b526e2c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
  1948
realize
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1949
    "scroll back to beginning when realized"
1268
da86fb7a9f12 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1950
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1951
    leftOffset := 0.
1274
a861b526e2c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
  1952
    super realize
1268
da86fb7a9f12 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  1953
1274
a861b526e2c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
  1954
    "Created: 24.7.1997 / 18:23:15 / cg"
125
claus
parents: 122
diff changeset
  1955
! !
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1956
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1957
!EditField methodsFor:'scrolling'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1958
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1959
makeColVisible:col inLine:lineNr
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1960
    "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
  1961
     is present."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1962
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1963
    |wText|
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1964
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1965
    (lengthLimit notNil 
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1966
    and:[col == cursorCol 
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1967
    and:[col > lengthLimit]]) ifTrue:[
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1968
        super makeColVisible:lengthLimit inLine:lineNr
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1969
    ] ifFalse:[
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1970
        super makeColVisible:col inLine:lineNr
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1971
    ].
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1972
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1973
    "/ new:
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1974
    "/ care to make the most possible visible
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1975
    leftOffset > 0 ifTrue:[
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1976
        wText := self widthOfLine:lineNr.
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1977
        wText <= self innerWidth ifTrue:[
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1978
            self scrollHorizontalTo:0
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1979
        ] ifFalse:[
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1980
            wText < (leftOffset+self innerWidth) ifTrue:[
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1981
                self scrollHorizontalTo:(wText - self innerWidth)
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1982
            ]
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1983
        ]
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  1984
    ]
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1985
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1986
    "Modified: 6.9.1995 / 13:57:53 / claus"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1987
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1988
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1989
!EditField methodsFor:'selections'!
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1990
1080
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1991
selectAll
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1992
    "select the whole text.
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1993
     redefined to send super selectFrom... since we dont want the
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1994
     cursor to be moved in this case."
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1995
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1996
    |len|
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1997
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1998
    list isNil ifTrue:[
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1999
        self unselect
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2000
    ] ifFalse:[
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2001
        len := (self listAt:1) size.
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2002
        len ~~ 0 ifTrue:[
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2003
            super selectFromLine:1 col:1 toLine:1 col:len.
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2004
        ].
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2005
        typeOfSelection := nil
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2006
    ]
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2007
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2008
    "Modified: 28.2.1997 / 19:16:21 / cg"
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2009
!
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2010
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2011
validateNewSelection
1654
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2012
    "make certain that only one line is ever selected"
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2013
1654
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2014
    selectionEndLine notNil ifTrue:[
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2015
        selectionEndLine > 1 ifTrue:[
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2016
            selectionEndLine := 2. selectionEndCol := 0
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2017
        ]
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2018
    ].
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2019
! !
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2020
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
  2021
!EditField class methodsFor:'documentation'!
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2022
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2023
version
1936
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  2024
    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.136 1999-06-28 13:45:21 tm Exp $'
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2025
! !