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