EditField.st
author Claus Gittinger <cg@exept.de>
Fri, 06 Mar 2020 21:56:26 +0100
changeset 6843 6c5e543e903e
parent 6811 a9e9675aca68
permissions -rw-r--r--
#OTHER by cg class: SimpleView added: #isWarningBox
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
5240
331c5840649e class: EditField
Claus Gittinger <cg@exept.de>
parents: 5122
diff changeset
    14
"{ NameSpace: Smalltalk }"
331c5840649e class: EditField
Claus Gittinger <cg@exept.de>
parents: 5122
diff changeset
    15
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    16
EditTextView subclass:#EditField
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
    17
	instanceVariableNames:'leaveAction enabled clickAction crAction tabAction converter
209
7a6db7fac566 dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    18
		leaveKeys immediateAccept acceptOnLeave acceptOnReturn
979
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
    19
		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
    20
		passwordCharacter autoScrollHorizontally acceptOnTab
3216
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
    21
		acceptOnLostFocus acceptOnPointerLeave acceptIfUnchanged leaveKey
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
    22
		doubleClickAction emptyFieldReplacementText leaveKeyActions
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
    23
		cancelKeys cancelKey cancelKeyActions'
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    24
	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
4013
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
    25
		DefaultSelectionForegroundColor DefaultSelectionBackgroundColor
6724
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
    26
		DefaultBorderColor DefaultBorderWidth DefaultLevel
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
    27
		FieldsHiddenAsPassword'
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    28
	poolDictionaries:''
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
    29
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    30
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    31
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
    32
!EditField class methodsFor:'documentation'!
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    33
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    34
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    35
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    36
 COPYRIGHT (c) 1990 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
    37
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    39
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    40
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    42
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    43
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    44
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    45
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    46
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    47
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    48
documentation
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
    49
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    50
    an editable text-field. Realized by using an EditTextView,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    51
    and forcing its size to 1 line - disabling cursor movement
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
    52
    in the vertical direction.
121
claus
parents: 120
diff changeset
    53
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    54
    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
    55
    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
    56
    (especially: #contents / #contents:).
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    57
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    58
    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
    59
    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
    60
    is extracted actively by someone else.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
    61
2737
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    62
    accepting:
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    63
      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
    64
      and let the field notify changes to it.
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    65
      This notification is called ``accepting''.
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    66
      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
    67
      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
    68
      uses of editFields are not interested in every individual change
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    69
      (i.e. getting each keyStroke when a long number is entered).
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    70
      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
    71
      key is pressed in a field.
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    72
      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
    73
      or on each individual key input.
6233
c0f9db3466e9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6222
diff changeset
    74
      See the method's #acceptOnLeave: / #acceptOnReturn: / #immediateAccept.
2737
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    75
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    76
      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
    77
      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
    78
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    79
    models value vs. field contents:
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    80
      Although the field internally keeps its contents as some string object,
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    81
      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
    82
      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
    83
      strings to/from the models domain value.
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    84
      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
    85
      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
    86
      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
    87
      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
    88
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    89
    grouping:
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    90
      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
    91
      outside, by placing multiple fields into an EnterFieldGroup.
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    92
      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
    93
      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
    94
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    95
    input completion:
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    96
      To support input completion (i.e. filename completion, classname completion etc.),
64329a4d4dd5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2709
diff changeset
    97
      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
    98
      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
    99
      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
   100
      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
   101
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   102
    special key handling:
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   103
      usually, editFields are embedded in a form (as in a dialog), 
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   104
      which has OK and Cancel buttons at the bottom.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   105
      However, if the editField is in some other popup, it may be required to customize its behavior
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   106
      upon certain key events. 
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   107
      For this, the following flags are used:
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   108
        leaveKeys       - the set of keys, which will lead to an accept (of the value into the model),
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   109
                          and leave the focus. If that happens, the responsible key is left in the leaveKey variable.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   110
                          Default are CursorUp, Down and Return
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   111
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   112
        leaveAction     - if not nil, that action is called after the accept, passing the leaveKey as argument
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   113
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   114
        acceptOnLeave   - if true, an accept will be performed on leave.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   115
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   116
        cancelKeys      - the set of keys which will leve without accepting. If that happens, the responsible
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   117
                          key is left in the cancelKey variable.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   118
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   119
        cancelAction    - if not nil, that action is called, passing the cancelKey as argument.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   120
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   121
        
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   122
    [Instance variables:]
121
claus
parents: 120
diff changeset
   123
claus
parents: 120
diff changeset
   124
      leaveAction    <Block | nil>              if non-nil, this is evaluated with
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   125
                                                the key (#Return, #CursorUp etc.) when
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   126
                                                the field is left via keyboard keys.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   127
                                                (fieldGroups use this to decide which
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   128
                                                 field has to be enabled next)
121
claus
parents: 120
diff changeset
   129
claus
parents: 120
diff changeset
   130
      enabled        <Boolean>                  if false, input is ignored.
claus
parents: 120
diff changeset
   131
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   132
      clickAction    <Block | nil>              action performed if the field is
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   133
                                                clicked upon.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   134
                                                (this is used by the group to
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   135
                                                 set the active field to the clicked upon field)
121
claus
parents: 120
diff changeset
   136
claus
parents: 120
diff changeset
   137
      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
   138
                                                handled specially, instead this block is evaluated
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   139
                                                (however, this block can perform additional checks and send
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   140
                                                 a #accept then)
121
claus
parents: 120
diff changeset
   141
claus
parents: 120
diff changeset
   142
      tabAction      <Block | nil>              if non-nil, keyboard input of a tab character
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   143
                                                is not entered into the text, instead this block
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   144
                                                is evaluated. Also, no input completion is performed if
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   145
                                                tabAction is nonNil.
121
claus
parents: 120
diff changeset
   146
claus
parents: 120
diff changeset
   147
      converter      <PrintConverter | nil>     if non-nil, this is supposed to convert between
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   148
                                                the object and its printed representation and vice versa.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   149
                                                Defaults to nil i.e. assume that strings are edited.
121
claus
parents: 120
diff changeset
   150
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   151
      leaveKeys      <Collection>               keys which are interpreted as 'leaving the field'
122
claus
parents: 121
diff changeset
   152
125
claus
parents: 122
diff changeset
   153
      immediateAccept   <Boolean>               if true, every change of the text is immediately
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   154
                                                forwarded to the model/acceptBlock. If false,
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   155
                                                the changed value is only stored in the model
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   156
                                                if the field is left or accepted.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   157
                                                Default is false.
122
claus
parents: 121
diff changeset
   158
claus
parents: 121
diff changeset
   159
      acceptOnLeave  <Boolean>                  if true, leaving the field (via cursor keys)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   160
                                                automatically accepts the value into the model.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   161
                                                Default is true.
122
claus
parents: 121
diff changeset
   162
claus
parents: 121
diff changeset
   163
      acceptOnReturn <Boolean>                  if true, leaving the field via return
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   164
                                                automatically accepts the value into the model.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   165
                                                Default is true.
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
      acceptOnTab    <Boolean>                  if true, the Tab key accepts and leaves the field.
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   168
                                                If false, Tabs are entered into the contents field like
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   169
                                                ordinary non-control keys.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   170
                                                AcceptOnTab is ignored if the entryCompletion block is nonNil.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   171
                                                Default is true.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   172
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   173
      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
   174
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   175
      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
   176
                                                when <entryCompletionCharacter> is pressed.
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   177
                                                Entry completion is used with Filenamefields or in the
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   178
                                                browser for classname/selector completion.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   179
                                                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
   180
2130
40515380f762 moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents: 2105
diff changeset
   181
      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
   182
                                                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
   183
                                                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
   184
                                                Default is #Tab.
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   185
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   186
      passwordCharacter     <CharacterOrNil>    if non-nil, typed input is replaced by this character
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   187
                                                for display. Used for secret-input fields (such as password entry).
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   188
                                                Default is nil.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   189
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   190
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   191
    [author:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   192
        Claus Gittinger
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   193
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   194
    [see also:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
   195
        DialogBox
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   196
        EnterFieldGroup
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   197
        EnterBox EnterBox2
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   198
        FilenameEditField EditTextView
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
   199
"
120
claus
parents: 118
diff changeset
   200
!
claus
parents: 118
diff changeset
   201
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   202
examples
120
claus
parents: 118
diff changeset
   203
"
122
claus
parents: 121
diff changeset
   204
    see more examples in EnterFieldGroup>>examples.
claus
parents: 121
diff changeset
   205
claus
parents: 121
diff changeset
   206
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   207
    Step-by-step introduction:
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   208
120
claus
parents: 118
diff changeset
   209
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   210
    basic field in some view:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   211
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   212
        |top field|
120
claus
parents: 118
diff changeset
   213
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   214
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   215
        top extent:200@100.
120
claus
parents: 118
diff changeset
   216
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   217
        field := EditField origin:0.0@0.0 in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   218
        field width:1.0.                                'let its height as-is'.
120
claus
parents: 118
diff changeset
   219
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   220
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   221
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   222
122
claus
parents: 121
diff changeset
   223
125
claus
parents: 122
diff changeset
   224
    forward input in topView to the field:
claus
parents: 122
diff changeset
   225
    (currently, the field does not know this - therefore,
claus
parents: 122
diff changeset
   226
     its been told here ... this may change)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   227
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   228
        |top field|
122
claus
parents: 121
diff changeset
   229
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   230
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   231
        top extent:200@100.
122
claus
parents: 121
diff changeset
   232
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   233
        field := EditField origin:0.0@0.0 in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   234
        field width:1.0.                                'let its height as-is'.
122
claus
parents: 121
diff changeset
   235
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   236
        top delegate:(KeyboardForwarder toView:field).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   237
        field hasKeyboardFocus:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   238
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   239
                                                                        [exEnd]
122
claus
parents: 121
diff changeset
   240
claus
parents: 121
diff changeset
   241
125
claus
parents: 122
diff changeset
   242
    to make it look better: set some inset:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   243
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   244
        |top field spacing|
120
claus
parents: 118
diff changeset
   245
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   246
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   247
        top extent:200@100.
120
claus
parents: 118
diff changeset
   248
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   249
        spacing := View viewSpacing.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   250
        field := EditField origin:(0.0 @ spacing) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   251
        field width:1.0.                                        'let its height as-is'.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   252
        field leftInset:spacing; rightInset:spacing.
120
claus
parents: 118
diff changeset
   253
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   254
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   255
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   256
122
claus
parents: 121
diff changeset
   257
120
claus
parents: 118
diff changeset
   258
    give it an initial contents:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   259
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   260
        |top field|
120
claus
parents: 118
diff changeset
   261
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   262
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   263
        top extent:200@100.
120
claus
parents: 118
diff changeset
   264
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   265
        field := EditField origin:(0.0 @ 0.0) in:top.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   266
        field width:1.0.
120
claus
parents: 118
diff changeset
   267
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   268
        field editValue:'hello world'.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   269
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   270
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   271
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   272
122
claus
parents: 121
diff changeset
   273
125
claus
parents: 122
diff changeset
   274
    have it preselected:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   275
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   276
        |top field|
120
claus
parents: 118
diff changeset
   277
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   278
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   279
        top extent:200@100.
120
claus
parents: 118
diff changeset
   280
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   281
        field := EditField origin:(0.0 @ 0.0) in:top.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   282
        field width:1.0.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   283
        field editValue:'hello world' selected:true.
120
claus
parents: 118
diff changeset
   284
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   285
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   286
                                                                         [exEnd]
120
claus
parents: 118
diff changeset
   287
122
claus
parents: 121
diff changeset
   288
120
claus
parents: 118
diff changeset
   289
    have part of it preselected:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   290
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   291
        |top field|
120
claus
parents: 118
diff changeset
   292
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   293
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   294
        top extent:200@100.
120
claus
parents: 118
diff changeset
   295
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   296
        field := EditField origin:(0.0 @ 0.0) in:top.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   297
        field width:1.0.
120
claus
parents: 118
diff changeset
   298
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   299
        field editValue:'hello world'.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   300
        field selectFromCharacterPosition:1 to:5.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   301
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   302
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   303
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   304
122
claus
parents: 121
diff changeset
   305
125
claus
parents: 122
diff changeset
   306
    set a size limit:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   307
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   308
        |top field|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   309
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   310
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   311
        top extent:200@100.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   312
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   313
        field := EditField origin:(0.0 @ 0.0) in:top.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   314
        field width:1.0.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   315
        field editValue:'hello'.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   316
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   317
        field maxChars:8.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   318
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   319
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   320
                                                                        [exEnd]
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   321
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   322
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   323
    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
   324
    notice: you may prefer a constant-pitch font (such as courier):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   325
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   326
        |top field|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   327
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   328
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   329
        top extent:200@100.
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
        field := EditField origin:(0.0 @ 0.0) in:top.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   332
        field innerWidth:(field font widthOf:'00000000').
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   333
        field editValue:'12345678'.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   334
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   335
        field maxChars:8.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   336
        field autoScroll:false.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   337
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   338
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   339
                                                                        [exEnd]
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   340
125
claus
parents: 122
diff changeset
   341
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   342
    enable / disable:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   343
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   344
        |top panel check field ena|
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   345
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   346
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   347
        top extent:200@100.
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
        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
   350
        panel borderWidth:0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   351
        panel horizontalLayout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   352
        panel horizontalInset:View viewSpacing.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   353
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   354
        check := CheckBox label:'enable' in:panel.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   355
        check turnOn.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   356
        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
   357
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   358
        panel add:(View new height:30; borderWidth:0).
125
claus
parents: 122
diff changeset
   359
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   360
        field := EditField in:panel.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   361
        field width:1.0.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   362
        field editValue:'hello'.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   363
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   364
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   365
                                                                        [exEnd]
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   366
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   367
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   368
    enable / disable using a channel:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   369
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   370
        |top panel check field ena|
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   371
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   372
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   373
        top extent:200@100.
125
claus
parents: 122
diff changeset
   374
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   375
        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
   376
        panel borderWidth:0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   377
        panel horizontalLayout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   378
        panel horizontalInset:View viewSpacing.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   379
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   380
        ena := true asValue.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   381
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   382
        check := CheckBox label:'enable' in:panel.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   383
        check model:ena.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   384
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   385
        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
   386
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   387
        field := EditField in:panel.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   388
        field enableChannel:ena.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   389
        field width:1.0.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   390
        field editValue:'hello'.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   391
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   392
        top open
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   393
                                                                        [exEnd]
125
claus
parents: 122
diff changeset
   394
claus
parents: 122
diff changeset
   395
121
claus
parents: 120
diff changeset
   396
    use a converter:
125
claus
parents: 122
diff changeset
   397
      - numbers (default to 0):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   398
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   399
        |top field spacing|
121
claus
parents: 120
diff changeset
   400
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   401
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   402
        top extent:200@100.
121
claus
parents: 120
diff changeset
   403
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   404
        spacing := View viewSpacing.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   405
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   406
        field := EditField origin:0.0 @ spacing in:top.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   407
        field width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   408
        field horizontalInset:spacing.
121
claus
parents: 120
diff changeset
   409
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   410
        field converter:(PrintConverter new initForNumber).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   411
        field editValue:1234.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   412
        field acceptAction:[:value | Transcript showCR:value].
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   413
        field crAction:[field accept. top destroy].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   414
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   415
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   416
claus
parents: 120
diff changeset
   417
      - dates:
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|
121
claus
parents: 120
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 initForDate).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   431
        field editValue:Date today.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   432
        field acceptAction:[:value | Transcript showCR:value class name , ' ' , value printString].
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   433
        field crAction:[field accept. top destroy].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   434
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   435
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   436
122
claus
parents: 121
diff changeset
   437
125
claus
parents: 122
diff changeset
   438
    setting immediateAccept, makes the field update with every key:
claus
parents: 122
diff changeset
   439
claus
parents: 122
diff changeset
   440
      - immediate accept numbers, defaulting to nil:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   441
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   442
        |top field spacing|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   443
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   444
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   445
        top extent:200@100.
121
claus
parents: 120
diff changeset
   446
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   447
        spacing := View viewSpacing.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   448
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   449
        field := EditField origin:0.0 @ spacing in:top.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   450
        field width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   451
        field horizontalInset:spacing.
121
claus
parents: 120
diff changeset
   452
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   453
        field converter:(PrintConverter new initForNumberOrNil).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   454
        field immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   455
        field editValue:1234.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   456
        field acceptAction:[:value | Transcript showCR:value].
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   457
        field crAction:[field accept. top destroy].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   458
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   459
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   460
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   461
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   462
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   463
    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
   464
    (i.e. actually: to the group):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   465
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   466
        |top field1 field2 field3 group|
121
claus
parents: 120
diff changeset
   467
122
claus
parents: 121
diff changeset
   468
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   469
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   470
        top extent:200@100.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   471
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   472
        field1 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   473
        field1 width:1.0.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   474
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   475
        field2 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   476
        field2 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   477
        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
   478
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   479
        field3 := EditField origin:(0.5 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   480
        field3 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   481
        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
   482
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   483
        group := EnterFieldGroup new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   484
        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
   485
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   486
        top delegate:(KeyboardForwarder to:group).
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
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   489
                                                                        [exEnd]
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   490
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   491
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   492
    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
   493
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   494
        |top field1 field2 field3 group|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   495
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   496
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   497
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   498
        top extent:200@100.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   499
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   500
        field1 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   501
        field1 width:1.0.
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   502
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   503
        field2 := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   504
        field2 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   505
        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
   506
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   507
        field3 := EditField origin:(0.5 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   508
        field3 width:0.5.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   509
        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
   510
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   511
        group := EnterFieldGroup new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   512
        group add:field1; add:field2; add:field3.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   513
        group leaveAction:[top destroy].
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   514
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   515
        top delegate:(KeyboardForwarder to:group).
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   516
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   517
        top open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   518
                                                                        [exEnd]
127
claus
parents: 125
diff changeset
   519
claus
parents: 125
diff changeset
   520
120
claus
parents: 118
diff changeset
   521
    use a model:
claus
parents: 118
diff changeset
   522
    (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
   523
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   524
        |top field model|
120
claus
parents: 118
diff changeset
   525
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   526
        model := 'hello world' asValue.
120
claus
parents: 118
diff changeset
   527
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   528
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   529
        top extent:200@100.
120
claus
parents: 118
diff changeset
   530
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   531
        field := EditField origin:(0.0 @ 0.0) in:top.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   532
        field width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   533
        field model:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   534
        field acceptOnReturn:true.
120
claus
parents: 118
diff changeset
   535
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   536
        top open.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   537
        model inspect.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   538
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   539
122
claus
parents: 121
diff changeset
   540
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   541
    like above, but also accept the value, when the focus is changed
894
210626ca9586 example
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   542
    (i.e. out of the input field):
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   543
    (see changing model value in inspector)
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   544
                                                                        [exBegin]
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   545
        |top field model|
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   546
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   547
        model := 'hello world' asValue.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   548
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   549
        top := StandardSystemView new.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   550
        top extent:200@100.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   551
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   552
        field := EditField origin:(0.0 @ 0.0) in:top.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   553
        field width:1.0.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   554
        field model:model.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   555
        field acceptOnLostFocus:true.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   556
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   557
        top open.
894
210626ca9586 example
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
   558
        InspectorView openOn:model monitor:'value'.
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   559
                                                                        [exEnd]
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   560
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   561
127
claus
parents: 125
diff changeset
   562
    two views on the same model (each accepts 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|
121
claus
parents: 120
diff changeset
   565
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   566
        model := 'hello world' asValue.
121
claus
parents: 120
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.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   573
        field1 acceptOnReturn:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   574
        top1 open.
121
claus
parents: 120
diff changeset
   575
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   576
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   577
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   578
        field2 := EditField origin:(0.0 @ 0.0) in:top2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   579
        field2 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   580
        field2 model:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   581
        field2 acceptOnReturn:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   582
        top2 open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   583
                                                                        [exEnd]
121
claus
parents: 120
diff changeset
   584
127
claus
parents: 125
diff changeset
   585
    two views on the same model (no accept on return):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   586
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   587
        |top1 top2 field1 field2 model|
127
claus
parents: 125
diff changeset
   588
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   589
        model := 'hello world' asValue.
127
claus
parents: 125
diff changeset
   590
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   591
        top1 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   592
        top1 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   593
        field1 := EditField origin:(0.0 @ 0.0) in:top1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   594
        field1 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   595
        field1 model:model; acceptOnReturn:false.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   596
        top1 open.
127
claus
parents: 125
diff changeset
   597
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   598
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   599
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   600
        field2 := EditField origin:(0.0 @ 0.0) in:top2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   601
        field2 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   602
        field2 model:model; acceptOnReturn:false.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   603
        top2 open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   604
                                                                        [exEnd]
127
claus
parents: 125
diff changeset
   605
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   606
    with immediate accept (every key updates the model):
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   607
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   608
        |top1 top2 field1 field2 model|
125
claus
parents: 122
diff changeset
   609
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   610
        model := 'hello world' asValue.
125
claus
parents: 122
diff changeset
   611
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   612
        top1 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   613
        top1 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   614
        field1 := EditField origin:(0.0 @ 0.0) in:top1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   615
        field1 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   616
        field1 model:model; immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   617
        top1 open.
125
claus
parents: 122
diff changeset
   618
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   619
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   620
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   621
        field2 := EditField origin:(0.0 @ 0.0) in:top2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   622
        field2 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   623
        field2 model:model; immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   624
        top2 open.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   625
                                                                        [exEnd]
122
claus
parents: 121
diff changeset
   626
121
claus
parents: 120
diff changeset
   627
    just an example; a checkBox and an editField on the same model:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   628
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   629
        |top1 top2 field1 box model|
121
claus
parents: 120
diff changeset
   630
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   631
        model := false asValue.
121
claus
parents: 120
diff changeset
   632
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   633
        top1 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   634
        top1 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   635
        field1 := EditField origin:(0.0 @ 0.0) in:top1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   636
        field1 width:1.0.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   637
        field1 converter:(PrintConverter new initForYesNo).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   638
        field1 model:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   639
        top1 open.
121
claus
parents: 120
diff changeset
   640
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   641
        top2 := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   642
        top2 extent:200@100.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   643
        box := CheckBox on:model.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   644
        box label:'on/off'.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   645
        top2 add:box.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   646
        top2 open.
121
claus
parents: 120
diff changeset
   647
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   648
        model inspect.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   649
                                                                        [exEnd]
125
claus
parents: 122
diff changeset
   650
claus
parents: 122
diff changeset
   651
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   652
    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
   653
    (the fields are connected by a group to allow tabbing)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   654
                                                                        [exBegin]
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   655
        |top panel group field1 field2 field3 box
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   656
         v1 v2 v3 spacing|
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   657
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   658
        v1 := true asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   659
        v2 := 'some string' asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   660
        v3 := 1.2 asValue.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   661
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   662
        top := StandardSystemView new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   663
        top extent:200@100.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   664
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   665
        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
   666
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   667
        spacing := View viewSpacing.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   668
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   669
        field1 := EditField new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   670
        field1 width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   671
        field1 horizontalInset:spacing.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   672
        field1 converter:(PrintConverter new initForYesNo).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   673
        field1 model:v1.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   674
        panel add:field1.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   675
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   676
        field2 := EditField new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   677
        field2 width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   678
        field2 horizontalInset:spacing.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   679
        field2 model:v2.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   680
        panel add:field2.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   681
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   682
        field3 := EditField new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   683
        field3 width:1.0.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   684
        field3 horizontalInset:spacing.
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   685
        field3 converter:(PrintConverter new initForNumber).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   686
        field3 model:v3.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   687
        panel add:field3.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   688
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   689
        group := EnterFieldGroup new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   690
        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
   691
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   692
        top openModal.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   693
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   694
        Transcript showCR:v1 value.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   695
        Transcript showCR:v2 value.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   696
        Transcript showCR:v3 value.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   697
                                                                        [exEnd]
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   698
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   699
125
claus
parents: 122
diff changeset
   700
    connecting fields:
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   701
    update field2 whenever field1 is changed.
125
claus
parents: 122
diff changeset
   702
    (normally, the processing below (xChanged) is done in your application
claus
parents: 122
diff changeset
   703
     class, or in a complex model. For the demonstration below, we use
claus
parents: 122
diff changeset
   704
     a Plug to simulate the protocol.)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   705
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   706
        |application top field1 field2 value1 value2|
125
claus
parents: 122
diff changeset
   707
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   708
        application := Plug new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   709
        application respondTo:#value1Changed
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   710
                         with:[value2 value:(value1 value isNil ifTrue:[nil]
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   711
                                                                ifFalse:[value1 value squared])].
125
claus
parents: 122
diff changeset
   712
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   713
        value1 := 1 asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   714
        value2 := 1 asValue.
125
claus
parents: 122
diff changeset
   715
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   716
        top := Dialog new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   717
        top extent:200@200.
125
claus
parents: 122
diff changeset
   718
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   719
        (top addTextLabel:'some number:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   720
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   721
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   722
        (top addInputFieldOn:value1 tabable:false)
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   723
            converter:(PrintConverter new initForNumberOrNil);
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   724
            immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   725
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   726
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   727
        (top addTextLabel:'squared:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   728
        top addVerticalSpace.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   729
        (top addInputFieldOn:value2 tabable:false)
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   730
            converter:(PrintConverter new initForNumberOrNil).
125
claus
parents: 122
diff changeset
   731
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   732
        value1 onChangeSend:#value1Changed to:application.
125
claus
parents: 122
diff changeset
   733
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   734
        top openModeless.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   735
                                                                        [exEnd]
125
claus
parents: 122
diff changeset
   736
claus
parents: 122
diff changeset
   737
claus
parents: 122
diff changeset
   738
    two-way connect:
claus
parents: 122
diff changeset
   739
    each field updates the other (notice, that we have to turn off
claus
parents: 122
diff changeset
   740
    onChange: notification, to avoid an endless notification cycle)
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   741
                                                                        [exBegin]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   742
        |application top field1 field2 value1 value2|
125
claus
parents: 122
diff changeset
   743
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   744
        application := Plug new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   745
        application respondTo:#value1Changed
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   746
                         with:[value2 retractInterestsFor:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   747
                               value2 value:(value1 value isNil ifTrue:[nil]
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   748
                                                                ifFalse:[value1 value squared]).
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   749
                               value2 onChangeSend:#value2Changed to:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   750
                              ].
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   751
        application respondTo:#value2Changed
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   752
                         with:[value1 retractInterestsFor:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   753
                               value1 value:(value2 value isNil ifTrue:[nil]
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   754
                                                                ifFalse:[value2 value sqrt]).
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
                              ].
125
claus
parents: 122
diff changeset
   757
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   758
        value1 := 1 asValue.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   759
        value2 := 1 asValue.
125
claus
parents: 122
diff changeset
   760
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   761
        top := Dialog new.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   762
        top extent:200@200.
125
claus
parents: 122
diff changeset
   763
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   764
        (top addTextLabel:'some number:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   765
        top addVerticalSpace.
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   766
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   767
        (top addInputFieldOn:value1 tabable:false)
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   768
            converter:(PrintConverter new initForNumberOrNil);
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   769
            immediateAccept:true.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   770
        top addVerticalSpace.
125
claus
parents: 122
diff changeset
   771
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   772
        (top addTextLabel:'squared:') layout:#left.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   773
        top addVerticalSpace.
6167
e9ee9ad33c30 #DOCUMENTATION by mawalch
mawalch
parents: 6139
diff changeset
   774
        (top addInputFieldOn:value2 tabable:false)
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   775
            converter:(PrintConverter new initForNumberOrNil);
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   776
            immediateAccept:true.
125
claus
parents: 122
diff changeset
   777
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   778
        value1 onChangeSend:#value1Changed to:application.
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   779
        value2 onChangeSend:#value2Changed to:application.
125
claus
parents: 122
diff changeset
   780
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   781
        top openModeless.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   782
                                                                        [exEnd]
120
claus
parents: 118
diff changeset
   783
"
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
   784
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   785
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   786
!EditField class methodsFor:'defaults'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   787
4028
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   788
defaultBorderColor
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   789
    ^ DefaultBorderColor
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   790
!
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   791
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   792
defaultBorderWidth
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   793
    ^ DefaultBorderWidth
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   794
!
Claus Gittinger <cg@exept.de>
parents: 4013
diff changeset
   795
125
claus
parents: 122
diff changeset
   796
defaultLeaveKeys
128
claus
parents: 127
diff changeset
   797
    "return the set of keys which are taken as leave-keys.
claus
parents: 127
diff changeset
   798
     If the field is in an enterFieldGroup, all leave keys will be
claus
parents: 127
diff changeset
   799
     forwarded to the group and possible step to the next/previous field.
claus
parents: 127
diff changeset
   800
     Also, if acceptOnLeave is true, leave keys will store the current
claus
parents: 127
diff changeset
   801
     value into their model (if any)"
claus
parents: 127
diff changeset
   802
125
claus
parents: 122
diff changeset
   803
    ^ #(Return CursorUp CursorDown Next Previous Accept)
claus
parents: 122
diff changeset
   804
!
claus
parents: 122
diff changeset
   805
4507
5d052c1b7f02 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4320
diff changeset
   806
defaultLevel
5d052c1b7f02 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4320
diff changeset
   807
    ^ DefaultLevel
5d052c1b7f02 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4320
diff changeset
   808
!
5d052c1b7f02 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4320
diff changeset
   809
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   810
defaultNumberOfLines
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   811
    "the number of lines in the field"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   812
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   813
    ^ 1
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   814
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   815
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   816
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   817
    "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
   818
4013
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
   819
    <resource: #style (#'editField.foregroundColor' 
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
   820
                       #'editField.backgroundColor'
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
   821
                       #'editField.selectionForegroundColor' 
4214
d98c74667441 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4212
diff changeset
   822
                       #'editField.selectionBackgroundColor'
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   823
                       #'editField.font')>
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   824
4910
eb2895fdb1d9 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
   825
    DefaultForegroundColor := StyleSheet colorAt:'editField.foregroundColor' default:Color black.
eb2895fdb1d9 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4896
diff changeset
   826
    DefaultBackgroundColor := StyleSheet colorAt:'editField.backgroundColor' default:Color white.
1834
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   827
    DefaultSelectionForegroundColor := StyleSheet colorAt:'editField.selectionForegroundColor' default:nil.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   828
    DefaultSelectionForegroundColor isNil ifTrue:[
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   829
        DefaultSelectionForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor' default:DefaultBackgroundColor.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   830
    ].
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   831
    DefaultSelectionBackgroundColor := StyleSheet colorAt:'editField.selectionBackgroundColor' default:nil.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   832
    DefaultSelectionBackgroundColor isNil ifTrue:[
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   833
        DefaultSelectionBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor' default:DefaultForegroundColor.
2cad8377f2e6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1829
diff changeset
   834
    ].
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   835
    DefaultFont := StyleSheet fontAt:'editField.font' default:nil.
4013
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
   836
    DefaultBorderColor := StyleSheet colorAt:'editField.borderColor' default:nil. 
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
   837
    DefaultBorderWidth := StyleSheet at:'editField.borderWidth' default:nil.  
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
   838
    DefaultLevel := StyleSheet at:'editField.level' default:nil. 
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   839
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   840
    "
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   841
     self updateStyleCache
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
   842
    "
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   843
4214
d98c74667441 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4212
diff changeset
   844
    "Modified: / 19-01-2011 / 22:34:35 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   845
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   846
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   847
!EditField methodsFor:'accepting'!
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   848
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   849
accept
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
   850
    "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
   851
     changeMessage.
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
   852
     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
   853
     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
   854
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
   855
    |string|
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   856
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   857
    acceptEnabled == false ifTrue:[
6268
3d8b11c7df18 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6255
diff changeset
   858
        self beepInEditor.
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   859
        ^ self
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   860
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   861
2105
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   862
    (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
   863
     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
   864
     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
   865
        ^ self
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
   866
    ].
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
   867
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   868
    super accept.
2105
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   869
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
   870
    "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
   871
     ('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
   872
     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
   873
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   874
    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
   875
        string := converter printStringFor:self editValue.
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   876
        string ~= self contents ifTrue:[
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   877
            self contents:string.
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   878
            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
   879
        ].
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   880
    ].
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   881
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   882
    "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
   883
! !
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   884
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   885
!EditField methodsFor:'accessing-behavior'!
125
claus
parents: 122
diff changeset
   886
2105
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   887
acceptIfUnchanged
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   888
    "return the acceptIfUnchanged flag setting.
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   889
     if set (the default), an accept notification is sent on accept,
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   890
     even if the fields value is the same. If cleared,
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   891
     the notification is suppressed, if the fields contents is the same."
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   892
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   893
    ^ acceptIfUnchanged
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   894
!
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   895
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   896
acceptIfUnchanged:aBoolean
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   897
    "if set (the default), an accept notification is sent on accept,
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   898
     even if the fields value is the same. If cleared,
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   899
     the notification is suppressed, if the fields contents is the same."
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   900
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   901
    acceptIfUnchanged := aBoolean
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   902
!
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
   903
2538
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   904
acceptOnLeave
6524
82b5d7bec604 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 6516
diff changeset
   905
    "return the acceptOnLeave flag. The default is false.
2538
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   906
     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
   907
     string into the valueHolder (if any).
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   908
     (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
   909
6524
82b5d7bec604 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 6516
diff changeset
   910
     ^ acceptOnLeave
82b5d7bec604 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 6516
diff changeset
   911
82b5d7bec604 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 6516
diff changeset
   912
    "Modified (comment): / 12-02-2019 / 10:25:50 / Stefan Vogel"
2538
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   913
!
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   914
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   915
acceptOnLeave:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   916
    "set/clear the acceptOnLeave flag. The default is false.
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   917
     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
   918
     string into the valueHolder (if any).
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   919
     (actually, the set of keys can be specified with #leaveKeys:)"
125
claus
parents: 122
diff changeset
   920
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   921
     acceptOnLeave := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   922
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   923
    "Modified: 11.12.1996 / 16:47:25 / cg"
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   924
!
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   925
3082
1a438d1ed699 acceptOnLostFocus getter added
penk
parents: 3046
diff changeset
   926
acceptOnLostFocus
1a438d1ed699 acceptOnLostFocus getter added
penk
parents: 3046
diff changeset
   927
    ^ acceptOnLostFocus
1a438d1ed699 acceptOnLostFocus getter added
penk
parents: 3046
diff changeset
   928
!
1a438d1ed699 acceptOnLostFocus getter added
penk
parents: 3046
diff changeset
   929
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   930
acceptOnLostFocus:aBoolean
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   931
    "set/clear the acceptOnLostFocus flag. The default is false.
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   932
     If true, a lost focus (via mouse-pointer motion etc.) accepts my 
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   933
     string into the valueHolder (if any)."
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   934
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   935
     acceptOnLostFocus := aBoolean
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   936
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   937
    "Modified: 16.12.1995 / 16:26:45 / cg"
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   938
    "Created: 11.12.1996 / 16:48:00 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   939
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   940
1937
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
   941
acceptOnPointerLeave:aBoolean
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
   942
    "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
   943
     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
   944
     string into the valueHolder (if any)."
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
   945
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
   946
     acceptOnPointerLeave := aBoolean
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
   947
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
   948
    "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
   949
    "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
   950
!
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
   951
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   952
acceptOnReturn:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   953
    "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
   954
     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
   955
     string into the valueHolder (if any)."
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   956
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   957
     acceptOnReturn := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   958
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   959
    "Modified: 16.12.1995 / 16:25:34 / cg"
125
claus
parents: 122
diff changeset
   960
!
claus
parents: 122
diff changeset
   961
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   962
acceptOnTab:aBoolean
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   963
    "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
   964
     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
   965
     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
   966
     (i.e. inserted into the contents)."
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   967
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   968
     acceptOnTab := aBoolean
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   969
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   970
    "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
   971
!
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
   972
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   973
autoScroll:aBoolean
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   974
    "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
   975
     to make the cursor visible."
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   976
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   977
    autoScrollHorizontally := aBoolean
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   978
!
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
   979
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   980
cancelKey
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   981
    "only valid after the editField has been left via a cancelCharacter.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   982
     Allows for users of the EditField to advance the selection 
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   983
     (especially: DataSets to select next/prev if editor is left via CrsrUp/Down).
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   984
     This is probably a stupid interface - better use onKey:cancelWith: for a directed action"
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   985
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   986
    ^ cancelKey
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   987
!
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   988
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   989
cancelKeys
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   990
    "return (a copy of) the collection of keys which are interpreted as cancelKeys.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   991
     I.e. those that make the field inactive and pass the focus to the next field
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   992
     (without accept)"
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   993
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   994
    ^ cancelKeys copy
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   995
!
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   996
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   997
cancelKeys:aCollectionOfKeySymbols 
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   998
    "define the set of keys which are interpreted as cancelKeys.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
   999
     I.e. those that make the field inactive without accept."
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1000
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1001
    cancelKeys := aCollectionOfKeySymbols
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1002
!
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1003
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1004
clickAction:aBlock
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1005
    "define an action to be evaluated when being clicked upon"
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1006
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1007
    clickAction := aBlock
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1008
!
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1009
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1010
converter
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1011
    "return the converter (if any)."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1012
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1013
    ^ converter
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1014
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1015
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1016
converter:aConverter
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1017
    "set the converter. If non-nil,
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1018
     the converter is applied to the text to convert from the string
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1019
     representation to the actual object value and vice versa.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1020
     The default converter is nil, meaning no-conversion
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1021
     (i.e. the edited object is the string itself."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1022
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1023
    converter := aConverter
6192
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1024
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1025
    "
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1026
     |field model|
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1027
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1028
     model := 0.5 asValue.
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1029
     field := EditField new.
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1030
     field model:model.
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1031
     field converter:(PrintConverter new initForNumber).
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1032
     model onChangeEvaluate:[ Transcript showCR: model value ].
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1033
     field open.
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1034
    "
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1035
3d0f6912e305 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6190
diff changeset
  1036
    "Modified (comment): / 24-08-2017 / 16:16:20 / cg"
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1037
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2779
diff changeset
  1038
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1039
crAction:aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1040
    "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
  1041
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1042
    crAction := aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1043
!
125
claus
parents: 122
diff changeset
  1044
3216
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1045
doubleClickAction:aBlock
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1046
    "define an action to be evaluated when being double clicked upon"
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1047
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1048
    doubleClickAction := aBlock
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1049
!
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1050
1034
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1051
enabled
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1052
    "return true, if the field is enabled (i.e. accepts keyboard input)"
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1053
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1054
    ^ enabled ? true 
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1055
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1056
!
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1057
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1058
enabled:aBoolean
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1059
    "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
  1060
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1061
    enabled ~~ aBoolean ifTrue:[
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1062
        enabled := aBoolean.
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1063
        self updateBackground.
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1064
        super cursorShown:aBoolean
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1065
    ]
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1066
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1067
    "Modified: / 3.8.1998 / 17:52:18 / cg"
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1068
    "Created: / 30.3.1999 / 15:19:17 / stefan"
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1069
    "Modified: / 30.3.1999 / 16:00:43 / stefan"
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1070
!
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1071
2993
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1072
entryCompletionBlock
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1073
    "the action to be evaluated when Tab (EntryCompletionCharacter) is pressed.
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1074
     The block gets the current contents and the field itself as optional arguments
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1075
     (i.e. it can be a 0, 1 or 2-arg block)."
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1076
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1077
    "/ read comment in entryCompletionBlockHolder: on why the following kludge is present
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1078
    entryCompletionBlock isBlock ifTrue:[
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1079
        ^ entryCompletionBlock
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1080
    ].
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1081
    ^ entryCompletionBlock value
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1082
!
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1083
2995
45b695aa5065 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2994
diff changeset
  1084
entryCompletionBlock:aZeroOneOrTwoArgBlock
2993
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1085
    "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
  1086
     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
  1087
     (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
  1088
2995
45b695aa5065 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2994
diff changeset
  1089
    entryCompletionBlock := aZeroOneOrTwoArgBlock
125
claus
parents: 122
diff changeset
  1090
!
claus
parents: 122
diff changeset
  1091
2995
45b695aa5065 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2994
diff changeset
  1092
entryCompletionBlockHolder:aZeroOneOrTwoArgBlock
2993
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1093
    "a holder for an action to be evaluated when Tab (EntryCompletionCharacter) is pressed.
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1094
     The block gets the current contents and the field itself as optional arguments
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1095
     (i.e. it can be a 0, 1 or 2-arg block)."
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1096
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1097
    "/ for now (to avoid incompatibilities), misuse the existing
6095
65ed08296dcb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5973
diff changeset
  1098
    "/ entryCompletionBlock and check if it's a holder.
2993
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1099
2995
45b695aa5065 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2994
diff changeset
  1100
    entryCompletionBlock := aZeroOneOrTwoArgBlock
6095
65ed08296dcb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5973
diff changeset
  1101
65ed08296dcb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5973
diff changeset
  1102
    "Modified (comment): / 13-02-2017 / 20:09:56 / cg"
2993
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1103
!
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1104
3990
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1105
entryCompletionCharacter
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1106
    "return the value of the instance variable 'entryCompletionCharacter' (automatically generated)"
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1107
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1108
    ^ entryCompletionCharacter
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1109
!
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1110
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1111
immediateAccept:aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1112
    "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
  1113
     If true, every pressed key immediately accepts my 
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1114
     string into the valueHolder (if any)."
155
claus
parents: 144
diff changeset
  1115
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1116
     immediateAccept := aBoolean
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1117
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1118
    "Modified: 16.12.1995 / 16:25:57 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1119
!
155
claus
parents: 144
diff changeset
  1120
995
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1121
isAcceptOnLeave
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1122
    "return the acceptOnLeave flag. The default is false.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1123
     If true, leaving the box (via return, cursor etc.) accepts my 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1124
     string into the valueHolder (if any).
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1125
     (actually, the set of keys can be specified with #leaveKeys:)"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1126
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1127
     ^ acceptOnLeave 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1128
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1129
    "Modified: 11.12.1996 / 16:47:25 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1130
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1131
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1132
isAcceptOnLostFocus
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1133
    "return the acceptOnLostFocus flag. The default is false.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1134
     If true, a lost focus (via mouse-pointer motion etc.) accepts my 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1135
     string into the valueHolder (if any)."
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1136
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1137
     ^ acceptOnLostFocus
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1138
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1139
    "Modified: 16.12.1995 / 16:26:45 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1140
    "Created: 11.12.1996 / 16:48:00 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1141
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1142
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1143
isAcceptOnReturn
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1144
    "return the acceptOnReturn flag. The default is false.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1145
     If true, leaving the box via return accepts my 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1146
     string into the valueHolder (if any)."
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1147
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1148
     ^ acceptOnReturn 
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1149
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1150
    "Modified: 16.12.1995 / 16:25:34 / cg"
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1151
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1152
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1153
isAcceptOnTab
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1154
    "return the acceptOnTab flag. The default is true.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1155
     If true, a pressed Tab key accepts and leaves the box.
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1156
     If false, the Tab key is treated like any normal input character
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1157
     (i.e. inserted into the contents)."
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1158
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1159
     ^ acceptOnTab
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1160
!
493b62566907 more isXXX queries
ca
parents: 994
diff changeset
  1161
994
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1162
isImmediateAccept
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1163
    "return the immediateAccept flag. The default is false.
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1164
     If true, every pressed key immediately accepts my 
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1165
     string into the valueHolder (if any)."
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1166
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1167
     ^ immediateAccept
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1168
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1169
    "Modified: 16.12.1995 / 16:25:57 / cg"
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1170
!
72ab84c42334 added #isImmediateAccept
ca
parents: 979
diff changeset
  1171
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1172
leaveAction:aBlock
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1173
    "define an action to be evaluated when field is left by a leave-key
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1174
     (by default: return or cursor keys.
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1175
     Actually, the set of keys can be specified with #leaveKeys:
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1176
     On leave, the precedence of actions is:
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1177
       1) explicit leaveAction per key
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1178
       2) this general leaveAction
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1179
       3) tab or return action
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1180
"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1181
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1182
    leaveAction := aBlock
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1183
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1184
    "Modified: 16.12.1995 / 16:26:36 / cg"
155
claus
parents: 144
diff changeset
  1185
!
claus
parents: 144
diff changeset
  1186
3990
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1187
leaveKey
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1188
    "only valid after the editField has been left via a leaveCharacter.
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1189
     Allows for users of the EditField to advance the selection 
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1190
     (especially: DataSets to select next/prev if editor is left via CrsrUp/Down).
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1191
     This is probably a stupid interface - better use onKey:leaveWith: for a directed action"
3990
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1192
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1193
    ^ leaveKey
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1194
!
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1195
1997
f509850c3240 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  1196
leaveKeys
1998
634d18238938 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
  1197
    "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
  1198
     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
  1199
     (and accept, if acceptOnLeave is true)"
1997
f509850c3240 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  1200
f509850c3240 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  1201
    ^ leaveKeys copy
f509850c3240 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  1202
!
f509850c3240 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  1203
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1204
leaveKeys:aCollectionOfKeySymbols 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1205
    "define the set of keys which are interpreted as leaveKeys.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1206
     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
  1207
     The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return."
155
claus
parents: 144
diff changeset
  1208
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1209
    leaveKeys := aCollectionOfKeySymbols
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1210
!
155
claus
parents: 144
diff changeset
  1211
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1212
makeTabable
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1213
    "arrange for Tab to accept & leave the field
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1214
     If the field is part of a group, the next field gets the
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1215
     input focus"
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1216
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1217
    leaveKeys isNil ifTrue:[
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1218
        leaveKeys := self class defaultLeaveKeys
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1219
    ].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1220
    leaveKeys := leaveKeys copyWith:#Tab
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1221
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1222
    "Created: 27.4.1996 / 17:09:48 / cg"
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1223
!
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1224
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1225
onKey:aKey cancelWith:aBlock
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1226
    "arrange for aKey to leave the field (without accept) and evaluate aBlock.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1227
     On cancel, the precedence of actions is:
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1228
       1) explicit cancelAction per key
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1229
       1) explicit leaveAction per key
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1230
       2) general leaveAction
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1231
       3) tab or return action
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1232
     Can be used to arrange for escape to deal with special operations (such as closing some view),
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1233
     The cancel-action block will be called with 0,1 (the key) or 2 (self + key) arguments"
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1234
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1235
    cancelKeys := (cancelKeys ? #()) asSet.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1236
    cancelKeys add:aKey.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1237
    cancelKeyActions isNil ifTrue:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1238
        cancelKeyActions := Dictionary new.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1239
    ].
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1240
    cancelKeyActions at:aKey put:aBlock.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1241
!
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1242
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1243
onKey:aKey leaveWith:aBlock
6389
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1244
    "arrange for aKey to leave the field and evaluate aBlock.
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1245
     On leave, the precedence of actions is:
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1246
       1) explicit leaveAction per key
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1247
       2) general leaveAction
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1248
       3) tab or return action
6389
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1249
     Can be used to arrange for cursorDown to pass focus to another widget,
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1250
     or to override builtin ctrl- shortcuts.
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1251
     The leave-action block will be called with 0,1 (the key) or 2 (self + key) arguments"
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1252
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1253
    leaveKeys := (leaveKeys ? #()) asSet.
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1254
    leaveKeys add:aKey.
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1255
    leaveKeyActions isNil ifTrue:[
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1256
        leaveKeyActions := Dictionary new.
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1257
    ].
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1258
    leaveKeyActions at:aKey put:aBlock.
6389
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1259
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1260
    "Modified (comment): / 09-08-2018 / 09:15:29 / Claus Gittinger"
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1261
!
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1262
1609
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1263
readOnly:aBoolean
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1264
    "make the text readonly or writable"
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1265
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1266
    super readOnly:aBoolean.
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  1267
    self updateBackground.
1609
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1268
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1269
    "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
  1270
    "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
  1271
!
8a0c1ee30a0a readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1272
1842
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1273
returnKeyIsFocusNext
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1274
    "arrange for the return key to act as a focus-next key"
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1275
3975
73674d16fc63 copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents: 3929
diff changeset
  1276
    leaveKeys := leaveKeys copyAsOrderedCollection. 
1842
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1277
    leaveKeys remove:#Return ifAbsent:nil
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1278
!
b5069ac92167 added #returnKeyIsFocusNext
Claus Gittinger <cg@exept.de>
parents: 1836
diff changeset
  1279
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1280
tabAction:aBlock
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1281
    "define an action to be evaluated when the tabulator key is pressed."
155
claus
parents: 144
diff changeset
  1282
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1283
    tabAction := aBlock
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1284
!
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1285
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1286
tabKey:aKeySymbol 
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1287
    "arrange for aKeySymbol to accept & leave the field
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1288
     If the field is part of a group, the next field gets the
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1289
     input focus"
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1290
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1291
    leaveKeys isNil ifTrue:[
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1292
        leaveKeys := self class defaultLeaveKeys
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1293
    ].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1294
    leaveKeys := leaveKeys copyWith:#Tab
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1295
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  1296
    "Created: 27.4.1996 / 17:08:54 / cg"
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1297
! !
125
claus
parents: 122
diff changeset
  1298
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1299
!EditField methodsFor:'accessing-contents'!
125
claus
parents: 122
diff changeset
  1300
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1301
contents
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1302
    "return contents as a string
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1303
     - redefined since EditFields hold only one line of text.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1304
    In your application, please use #editValue; 
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1305
    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
  1306
3706
d25f10e7b49b #accept only, if the text field has been modified (DrawAdaptor compatibility)
Stefan Vogel <sv@exept.de>
parents: 3704
diff changeset
  1307
    (list isEmptyOrNil) ifTrue:[^ ''].
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1308
    ^ list at:1
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1309
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1310
125
claus
parents: 122
diff changeset
  1311
contents:someText
claus
parents: 122
diff changeset
  1312
    "set the contents from a string
claus
parents: 122
diff changeset
  1313
     - 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
  1314
    In your application, please use #editValue: - 
125
claus
parents: 122
diff changeset
  1315
    it uses a converter (if any) and is compatible to ST-80."
claus
parents: 122
diff changeset
  1316
1180
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1317
    |newCol txt|
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1318
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1319
    newCol := cursorCol.
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1320
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1321
    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
  1322
        txt := ''.
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1323
    ] ifFalse:[
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1324
        txt := someText asString.
1180
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1325
    ].
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1326
    super contents:txt.
125
claus
parents: 122
diff changeset
  1327
2130
40515380f762 moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents: 2105
diff changeset
  1328
    (cursorMovementWhenUpdating == #endOfLine
40515380f762 moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents: 2105
diff changeset
  1329
    or:[cursorMovementWhenUpdating == #endOfText
40515380f762 moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents: 2105
diff changeset
  1330
    or:[cursorMovementWhenUpdating == #end]]) ifTrue:[
1180
abe00ac05e27 oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
  1331
         newCol := (txt size + 1).
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1332
    ] ifFalse:[
2130
40515380f762 moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents: 2105
diff changeset
  1333
        (cursorMovementWhenUpdating == #beginOfLine
40515380f762 moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents: 2105
diff changeset
  1334
        or:[cursorMovementWhenUpdating == #beginOfText
40515380f762 moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents: 2105
diff changeset
  1335
        or:[cursorMovementWhenUpdating == #begin]]) ifTrue:[
1179
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1336
            newCol := 1
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1337
        ] ifFalse:[
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1338
            "/ default: stay where it was
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1339
        ]
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1340
    ].
125
claus
parents: 122
diff changeset
  1341
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1342
    self cursorCol:newCol.
1179
7ae3148ca2e4 convert to string.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
  1343
2042
7080474e7966 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2016
diff changeset
  1344
    "Modified: / 13.11.1999 / 13:50:30 / cg"
125
claus
parents: 122
diff changeset
  1345
!
claus
parents: 122
diff changeset
  1346
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1347
convertEditValueToString:aStringOrObject
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1348
    "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
  1349
     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
  1350
     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
  1351
     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
  1352
     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
  1353
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1354
    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
  1355
        ^ 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
  1356
    ].
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1357
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1358
    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
  1359
        ^ ''.
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1360
    ].
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1361
    ^ aStringOrObject asString.
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1362
!
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1363
125
claus
parents: 122
diff changeset
  1364
editValue
claus
parents: 122
diff changeset
  1365
    "if the field edits a string, this is a name alias for #contents.
claus
parents: 122
diff changeset
  1366
     Otherwise, if there is a converter, return the edited string
claus
parents: 122
diff changeset
  1367
     converted to an appropriate object."
claus
parents: 122
diff changeset
  1368
claus
parents: 122
diff changeset
  1369
    |string|
claus
parents: 122
diff changeset
  1370
claus
parents: 122
diff changeset
  1371
    string := self contents.
279
b9fa9180aca4 empty strings are not nil
ca
parents: 261
diff changeset
  1372
    string isNil ifTrue:[string := ''].
125
claus
parents: 122
diff changeset
  1373
    converter isNil ifTrue:[^ string].
claus
parents: 122
diff changeset
  1374
    ^ converter readValueFrom:string 
claus
parents: 122
diff changeset
  1375
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1376
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1377
editValue:anObject
125
claus
parents: 122
diff changeset
  1378
    "set the contents. If there is a converter, use it to convert
claus
parents: 122
diff changeset
  1379
     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
  1380
     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
  1381
     (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
  1382
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1383
    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
  1384
!
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1385
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1386
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
  1387
    "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
  1388
     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
  1389
     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
  1390
     (i.e. this is equivalent to sending #initialText:selected:)."
125
claus
parents: 122
diff changeset
  1391
claus
parents: 122
diff changeset
  1392
    |string|
claus
parents: 122
diff changeset
  1393
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1394
    string := self convertEditValueToString:anObject.
125
claus
parents: 122
diff changeset
  1395
    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
  1396
    isSelected ifTrue:[
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1397
        self selectFromLine:1 col:1 toLine:1 col:string size.
125
claus
parents: 122
diff changeset
  1398
    ]
claus
parents: 122
diff changeset
  1399
!
claus
parents: 122
diff changeset
  1400
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1401
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
  1402
    "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
  1403
     Better use #editValue: - it uses the type converter."
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1404
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1405
    self initialText:aString selected:true
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1406
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1407
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1408
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
  1409
    "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
  1410
     Better use #editValue:selected: - it uses the type converter."
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1411
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1412
    |len s|
125
claus
parents: 122
diff changeset
  1413
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1414
    viewOrigin := 0 @ viewOrigin y.
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1415
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1416
    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
  1417
    isSelected ifTrue:[
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1418
        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
  1419
        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
  1420
        len ~~ 0 ifTrue:[
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1421
            self selectFromLine:1 col:1 toLine:1 col:len
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1422
        ]
3709
a17acdae3e35 Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents: 3706
diff changeset
  1423
    ].
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1424
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1425
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1426
list:someText
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1427
    "low level access to the underlying contents' list.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1428
     Redefined to force text to 1 line, and notify dependents
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1429
     of any changed extent-wishes (for automatic box resizing)."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1430
6195
076be3d30b41 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6192
diff changeset
  1431
    |l oldWidth newWidth|
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1432
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1433
    l := someText.
4992
7d8b66d3c846 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4991
diff changeset
  1434
    l notEmptyOrNil ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1435
        l := OrderedCollection with:(l at:1)
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1436
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1437
    oldWidth := self widthOfContents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1438
    super list:l.
6195
076be3d30b41 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6192
diff changeset
  1439
    newWidth := self widthOfContents.
076be3d30b41 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6192
diff changeset
  1440
    (newWidth > oldWidth and:[newWidth > self innerWidth]) ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1441
        self changedPreferredBounds:nil
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1442
    ]
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1443
6195
076be3d30b41 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6192
diff changeset
  1444
    "Modified: / 24-08-2017 / 17:00:01 / cg"
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1445
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1446
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1447
stringValue
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1448
    "alias for #contents - for compatibility with ST-80's InputField"
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1449
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1450
    ^ self contents
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1451
! !
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1452
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1453
!EditField methodsFor:'accessing-look'!
125
claus
parents: 122
diff changeset
  1454
3585
16dfdbd231c2 +bePassword
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
  1455
bePassword
16dfdbd231c2 +bePassword
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
  1456
    "make me a password entry field (i.e. show *'s for typed characters"
16dfdbd231c2 +bePassword
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
  1457
16dfdbd231c2 +bePassword
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
  1458
    self passwordCharacter:$*
16dfdbd231c2 +bePassword
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
  1459
!
16dfdbd231c2 +bePassword
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
  1460
6512
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1461
bePassword:aBoolean
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1462
    "if true, make me a password entry field (i.e. show *'s for typed characters"
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1463
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1464
    self passwordCharacter:(aBoolean ifTrue:[$*] ifFalse:[nil]).
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1465
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1466
    "Created: / 05-12-2018 / 17:37:13 / Stefan Vogel"
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1467
!
9da0a1ceba4f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6489
diff changeset
  1468
3990
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1469
emptyFieldReplacementText
3991
9bf5fb90853f comments:
Claus Gittinger <cg@exept.de>
parents: 3990
diff changeset
  1470
    "the string to show in grey if nothing has been entered (and the field is passive)"
3990
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1471
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1472
    ^ emptyFieldReplacementText
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1473
!
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1474
6453
b98c935b55aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6442
diff changeset
  1475
emptyFieldReplacementText:aString
3991
9bf5fb90853f comments:
Claus Gittinger <cg@exept.de>
parents: 3990
diff changeset
  1476
    "the string to show in grey if nothing has been entered (and the field is passive)"
3990
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1477
6453
b98c935b55aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6442
diff changeset
  1478
    emptyFieldReplacementText := aString.
b98c935b55aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6442
diff changeset
  1479
    self invalidate.
3990
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1480
!
6a7e190c11cd category of:
Claus Gittinger <cg@exept.de>
parents: 3988
diff changeset
  1481
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1482
font:aFont
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1483
    super font:aFont.
5044
db43a967ff95 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5043
diff changeset
  1484
    realized ifTrue:[ self computeTopMargin ].
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1485
!
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1486
155
claus
parents: 144
diff changeset
  1487
maxChars
claus
parents: 144
diff changeset
  1488
    "return the maximum number of characters that are allowed in
claus
parents: 144
diff changeset
  1489
     the field. 
claus
parents: 144
diff changeset
  1490
     A limit of nil means: unlimited. This is the default."
claus
parents: 144
diff changeset
  1491
claus
parents: 144
diff changeset
  1492
    ^ lengthLimit
claus
parents: 144
diff changeset
  1493
claus
parents: 144
diff changeset
  1494
    "Modified: 6.9.1995 / 13:43:33 / claus"
claus
parents: 144
diff changeset
  1495
!
claus
parents: 144
diff changeset
  1496
125
claus
parents: 122
diff changeset
  1497
maxChars:aNumberOrNil
claus
parents: 122
diff changeset
  1498
    "set the maximum number of characters that are allowed in
claus
parents: 122
diff changeset
  1499
     the field. Additional input will be ignored by the field.
1034
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1500
     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
  1501
     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
  1502
     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
  1503
     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
  1504
125
claus
parents: 122
diff changeset
  1505
     This method has been renamed from #lengthLimit: for ST-80
claus
parents: 122
diff changeset
  1506
     compatibility."
claus
parents: 122
diff changeset
  1507
1034
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1508
    aNumberOrNil == 0 ifTrue:[
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1509
        lengthLimit := nil
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1510
    ] ifFalse:[
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1511
        lengthLimit := aNumberOrNil.
d6d5d222f166 added #enabled.
ca
parents: 995
diff changeset
  1512
    ]
187
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1513
!
1a429506fad6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1514
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1515
passwordCharacter
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1516
    "return the passwordCharacter;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1517
     If nonNil, that one is replacing typed input
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1518
     (for secret input)"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1519
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1520
    ^ passwordCharacter
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1521
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1522
    "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
  1523
    "Modified: 16.12.1995 / 16:24:25 / cg"
125
claus
parents: 122
diff changeset
  1524
!
claus
parents: 122
diff changeset
  1525
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1526
passwordCharacter:aCharacter
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1527
    "set the passwordCharacter;
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1528
     If nonNil, that one is replacing typed input
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1529
     (for secret input)"
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  1530
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1531
    passwordCharacter := aCharacter
97
cbf495fe3b64 *** empty log message ***
claus
parents: 77
diff changeset
  1532
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1533
    "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
  1534
    "Modified: 16.12.1995 / 16:24:33 / cg"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
  1535
! !
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 19
diff changeset
  1536
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1537
!EditField methodsFor:'cursor drawing'!
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1538
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1539
cursorShown:aBoolean
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1540
    "make cursor visible if currently invisible - but only if this
1880
3ad00c12541e comment
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1541
     EditField is enabled. 
3ad00c12541e comment
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1542
     Return the previous cursor-shown-state"
1399
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1543
1836
97361bf30af6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1834
diff changeset
  1544
    ^ super cursorShown:(aBoolean and:[enabled and:[self isReadOnly not]])
1399
a3dd97770d99 release channels on destroy
Claus Gittinger <cg@exept.de>
parents: 1372
diff changeset
  1545
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1546
    "Created: / 30.3.1999 / 16:00:25 / stefan"
1880
3ad00c12541e comment
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1547
    "Modified: / 1.4.1999 / 11:18:38 / cg"
1829
30b8981385f4 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1826
diff changeset
  1548
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1549
155
claus
parents: 144
diff changeset
  1550
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
claus
parents: 144
diff changeset
  1551
    startVisLineNr to:endVisLineNr do:[:visLine |
claus
parents: 144
diff changeset
  1552
	self drawVisibleLine:visLine with:fg and:bg
claus
parents: 144
diff changeset
  1553
    ]
claus
parents: 144
diff changeset
  1554
claus
parents: 144
diff changeset
  1555
    "Modified: 6.9.1995 / 12:24:29 / claus"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1556
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1557
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1558
!EditField methodsFor:'cursor movement'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1559
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1560
cursorDown
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1561
    "catch cursor movement"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1562
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1563
    (cursorVisibleLine == nLinesShown) ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 47
diff changeset
  1564
	super cursorDown
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1565
    ]
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1566
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1567
6222
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  1568
cursorLeft
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  1569
    super cursorLeft
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  1570
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  1571
    "Created: / 23-10-2017 / 18:28:38 / cg"
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  1572
!
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  1573
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1574
cursorLine:line col:col
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1575
    "catch cursor movement"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1576
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1577
    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
  1578
!
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1579
5055
392e14014bba class: EditField
Claus Gittinger <cg@exept.de>
parents: 5044
diff changeset
  1580
cursorLine:line col:col makeVisible:aBoolean
392e14014bba class: EditField
Claus Gittinger <cg@exept.de>
parents: 5044
diff changeset
  1581
    "catch cursor movement"
392e14014bba class: EditField
Claus Gittinger <cg@exept.de>
parents: 5044
diff changeset
  1582
392e14014bba class: EditField
Claus Gittinger <cg@exept.de>
parents: 5044
diff changeset
  1583
    super cursorLine:1 col:col makeVisible:aBoolean
392e14014bba class: EditField
Claus Gittinger <cg@exept.de>
parents: 5044
diff changeset
  1584
!
392e14014bba class: EditField
Claus Gittinger <cg@exept.de>
parents: 5044
diff changeset
  1585
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1586
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
  1587
    "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
  1588
     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
  1589
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1590
    |sz|
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1591
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1592
    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
  1593
    lengthLimit notNil ifTrue:[
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1594
        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
  1595
    ].
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1596
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1597
    col <= sz ifTrue:[
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1598
        ^ col
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1599
    ].
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1600
    ^ 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
  1601
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1602
    "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
  1603
    "Modified: 22.5.1996 / 18:19:04 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1604
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1605
3413
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1606
!EditField methodsFor:'drag & drop'!
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1607
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1608
dropFileObject:aDropObject
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1609
    "drop objects
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1610
     Redefined to always drop the name only"
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1611
3797
69edb2e7436c code formatting
Claus Gittinger <cg@exept.de>
parents: 3768
diff changeset
  1612
    self 
4115
d72bec20db99 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
  1613
        undoablePasteReplacingAll:(aDropObject asFilename pathName) 
3797
69edb2e7436c code formatting
Claus Gittinger <cg@exept.de>
parents: 3768
diff changeset
  1614
        info:'Drop Filename'.
3413
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1615
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1616
    "Created: / 13-10-2006 / 17:42:22 / cg"
3494
34917a0f9072 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3462
diff changeset
  1617
    "Modified: / 28-07-2007 / 13:27:32 / cg"
3413
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1618
! !
49d0f37f0616 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
  1619
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1620
!EditField methodsFor:'editing'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1621
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1622
paste:someText
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1623
    "redefined to force text to 1 line"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1624
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1625
    super paste:someText.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1626
    list size > 1 ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1627
	self deleteFromLine:2 toLine:(list size)
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1628
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1629
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1630
70
14443a9ea4ec *** empty log message ***
claus
parents: 62
diff changeset
  1631
!EditField methodsFor:'event handling'!
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1632
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1633
buttonPress:button x:x y:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1634
    "enable myself on mouse click"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1635
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1636
    |prevFocus|
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1637
3703
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1638
    enabled ifTrue:[
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1639
        prevFocus := hasKeyboardFocus.
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1640
        clickAction notNil ifTrue:[
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1641
            clickAction value:self
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1642
        ].
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1643
        hasKeyboardFocus ~~ prevFocus ifTrue:[
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1644
            ^ self
5463ea3878b0 you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents: 3702
diff changeset
  1645
        ].
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1646
    ].
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1647
    super buttonPress:button x:x y:y
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1648
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1649
"/    enabled ifFalse:[
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1650
"/        enabled := true.
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1651
"/        super buttonPress:button x:x y:y.
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1652
"/        enableAction notNil ifTrue:[
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1653
"/            enableAction value
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1654
"/        ]
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1655
"/    ] ifTrue:[
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1656
"/        super buttonPress:button x:x y:y
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1657
"/    ]
333
f1c500f177d8 handle disabled state
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
  1658
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  1659
    "Modified: 22.5.1996 / 15:02:45 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1660
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1661
6117
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1662
buttonRelease:button x:x y:y
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1663
    "if the selection is empty (because of validateSelection, 
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1664
     clear it alltogether, so that the cursor becomes visible again"
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1665
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1666
    (selectionStartCol notNil and:[selectionEndCol notNil
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1667
      and:[ selectionStartLine == 1 and:[selectionEndLine == 1]]]) ifTrue:[
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1668
        selectionEndCol < selectionStartCol ifTrue:[
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1669
            selectionStartCol := selectionEndCol := nil.
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1670
            selectionStartLine := selectionEndLine := nil.
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1671
        ]
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1672
    ].
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1673
    super buttonRelease:button x:x y:y
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1674
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1675
    "Created: / 07-03-2017 / 15:52:56 / cg"
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1676
!
026e468c7585 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6116
diff changeset
  1677
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1678
canHandle:aKey
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1679
    "return true, if the receiver would like to handle aKey
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1680
     (usually from another view, when the receiver is part of
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1681
      a more complex dialog box).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1682
     We do return true here, since the editfield will handle
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1683
     all keys.
5594
09e1ac49efce #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5542
diff changeset
  1684
     OBSOLETE: don't use this anymore - its a leftover for the tableWidget"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1685
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1686
    ^ true
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1687
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1688
3216
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1689
doubleClickX:x y:y
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1690
    doubleClickAction notNil ifTrue: [
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1691
        doubleClickAction value.
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1692
    ].
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1693
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1694
    super doubleClickX:x y:y
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1695
!
8161c0b4b38e add double click action
ab
parents: 3082
diff changeset
  1696
4608
7c0f79a2d2d8 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1697
handleCompletionService
7c0f79a2d2d8 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1698
    "none here"
7c0f79a2d2d8 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1699
7c0f79a2d2d8 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1700
    ^ self
7c0f79a2d2d8 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1701
!
7c0f79a2d2d8 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4540
diff changeset
  1702
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1703
handleFocusKey:key
3535
1c9f308b2eec comment
Claus Gittinger <cg@exept.de>
parents: 3494
diff changeset
  1704
    "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
  1705
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1706
    <resource: #keyboard (#Tab #Return #CursorDown #CursorUp)>
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1707
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1708
    windowGroup isNil ifTrue:[^ self ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1709
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1710
    (key == #Tab) ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1711
        (self tabRequiresControl not
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1712
        or:[ self sensor ctrlDown ]) ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1713
            self sensor shiftDown ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1714
                windowGroup focusPrevious
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1715
            ] ifFalse:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1716
                windowGroup focusNext
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1717
            ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1718
        ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1719
        ^ self
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1720
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1721
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1722
    (key == #Return) ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1723
        windowGroup focusNext.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1724
        ^ self
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1725
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1726
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1727
    key == #CursorDown ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1728
        windowGroup focusNext.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1729
        ^ self.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1730
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1731
    key == #CursorUp ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1732
        windowGroup focusPrevious.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1733
        ^ self.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1734
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1735
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1736
    "Created: / 06-03-2007 / 20:14:04 / cg"
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1737
!
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1738
125
claus
parents: 122
diff changeset
  1739
keyPress:key x:x y:y
claus
parents: 122
diff changeset
  1740
    "if keyHandler is defined, pass input; otherwise check for leave
claus
parents: 122
diff changeset
  1741
     keys"
claus
parents: 122
diff changeset
  1742
490
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 480
diff changeset
  1743
    <resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 894
diff changeset
  1744
                          #DeleteLine #GotoLine #EndOfLine #EndOfText
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 894
diff changeset
  1745
                          #CursorDown #CursorUp)>
132
claus
parents: 131
diff changeset
  1746
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1747
    |rawKey leave cancel doAccept keyAction numArgs lastEvent|
125
claus
parents: 122
diff changeset
  1748
claus
parents: 122
diff changeset
  1749
    enabled ifFalse:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1750
        ^ self
125
claus
parents: 122
diff changeset
  1751
    ].
claus
parents: 122
diff changeset
  1752
claus
parents: 122
diff changeset
  1753
    (key == #DeleteLine) ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1754
        Smalltalk at:#CopyBuffer put:(self contents).
3797
69edb2e7436c code formatting
Claus Gittinger <cg@exept.de>
parents: 3768
diff changeset
  1755
        self contents:''. 
69edb2e7436c code formatting
Claus Gittinger <cg@exept.de>
parents: 3768
diff changeset
  1756
        ^ self
125
claus
parents: 122
diff changeset
  1757
    ].
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1758
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1759
    (key == entryCompletionCharacter and:[self entryCompletionBlock notNil]) ifTrue:[
6305
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  1760
        self doCompletion.
979
c71f75bb9ffc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 978
diff changeset
  1761
        ^ self
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1762
    ].
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1763
125
claus
parents: 122
diff changeset
  1764
    (key == #Tab) ifTrue:[
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1765
        doAccept := acceptOnTab.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1766
        keyAction := tabAction.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1767
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1768
    (key == #Return) ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1769
        doAccept := acceptOnReturn.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1770
        keyAction := crAction.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1771
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1772
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1773
    lastEvent := WindowGroup lastEvent.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1774
    (lastEvent notNil and:[lastEvent isKeyEvent]) ifTrue:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1775
        rawKey := lastEvent rawKey.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1776
    ].
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1777
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1778
    cancel := leave := false.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1779
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1780
    cancel := (cancelKeys ? #()) includes:key.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1781
    cancel ifFalse:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1782
        cancel := (cancelKeys ? #()) includes:rawKey.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1783
        cancel ifFalse:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1784
            leave := (leaveKeys ? #()) includes:key.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1785
            leave ifFalse:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1786
                leave := (leaveKeys ? #()) includes:rawKey.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1787
            ].
6516
1df1200a6040 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6512
diff changeset
  1788
        ].
1df1200a6040 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6512
diff changeset
  1789
    ].
6708
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1790
    cancel ifTrue:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1791
        cancelKey := key.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1792
        doAccept := false.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1793
    ] ifFalse:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1794
        leave ifTrue:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1795
            leaveKey := key.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1796
            doAccept := doAccept ? acceptOnLeave.
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1797
        ].
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1798
    ].
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1799
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1800
    cancel ifTrue:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1801
        "/ on cancel, the precedence of actions is:
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1802
        "/  1) explicit cancelAction per key
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1803
        cancelKeyActions notNil ifTrue:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1804
            keyAction := cancelKeyActions 
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1805
                            at:key 
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1806
                            ifAbsent:[
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1807
                                cancelKeyActions
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1808
                                    at:rawKey 
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1809
                                    ifAbsent:nil].
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1810
        ].
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1811
    ].
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1812
    ((cancel and:[keyAction isNil])
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1813
      or:[cancel not and:[leave]]
f11899d4bd49 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6694
diff changeset
  1814
    ) ifTrue:[
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1815
        "/ on leave, the precedence of actions is:
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1816
        "/  1) explicit leaveAction per key
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1817
        "/  2) general leaveAction
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1818
        "/  3) tab or return action
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1819
        leaveKeyActions notNil ifTrue:[
6389
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1820
            keyAction := leaveKeyActions 
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1821
                            at:key 
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1822
                            ifAbsent:[
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1823
                                leaveKeyActions 
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1824
                                    at:rawKey 
6392
22ceac28ebca #BUGFIX by Maren
matilk
parents: 6389
diff changeset
  1825
                                    ifAbsent:[keyAction]].
4720
1a78fc5a39d7 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1826
        ].
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1827
        keyAction := keyAction ? leaveAction.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1828
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1829
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1830
    doAccept == true ifTrue:[
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1831
        self accept.
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1832
    ].
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1833
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1834
    keyAction notNil ifTrue:[
6694
9422f9cb3c30 #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6524
diff changeset
  1835
        numArgs := keyAction argumentCount.
3462
447eb65a523f check for numArgs == 0 before evaluating the keyAction
boris
parents: 3461
diff changeset
  1836
        numArgs == 2 ifTrue:[
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1837
            ^ 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
  1838
        ].
3462
447eb65a523f check for numArgs == 0 before evaluating the keyAction
boris
parents: 3461
diff changeset
  1839
        numArgs == 0 ifTrue:[
447eb65a523f check for numArgs == 0 before evaluating the keyAction
boris
parents: 3461
diff changeset
  1840
            ^ keyAction value
447eb65a523f check for numArgs == 0 before evaluating the keyAction
boris
parents: 3461
diff changeset
  1841
        ].
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1842
        ^ keyAction value:key
125
claus
parents: 122
diff changeset
  1843
    ].
480
dd6263c5f9ee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
  1844
125
claus
parents: 122
diff changeset
  1845
    leave ifTrue:[
611
87637cf3931b Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents: 601
diff changeset
  1846
        (x notNil and:[x >= 0]) ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1847
            "
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1848
             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
  1849
             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
  1850
            "
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1851
            (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1852
                superView keyPress:key x:x y:y.
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1853
            ].
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1854
        ].
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1855
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1856
        "/ 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
  1857
        "/ 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
  1858
        key == #CursorDown ifTrue:[
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1859
            self handleFocusKey:key.
2708
dfdf8977e9ba care for nil windogroup (editor in dataSet)
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
  1860
            ^ self.
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1861
        ].
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1862
        key == #CursorUp ifTrue:[
3460
98524ea0fea6 tab handling;
Claus Gittinger <cg@exept.de>
parents: 3413
diff changeset
  1863
            self handleFocusKey:key.
2708
dfdf8977e9ba care for nil windogroup (editor in dataSet)
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
  1864
            ^ self.
737
911a168ef967 handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents: 725
diff changeset
  1865
        ].
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1866
        ^ self
19
a696fb528758 *** empty log message ***
claus
parents: 7
diff changeset
  1867
    ].
121
claus
parents: 120
diff changeset
  1868
125
claus
parents: 122
diff changeset
  1869
    "
claus
parents: 122
diff changeset
  1870
     ignore some keys (if not a leaveKey) ...
claus
parents: 122
diff changeset
  1871
    "
claus
parents: 122
diff changeset
  1872
    (key == #Find) ifTrue:[^self].
claus
parents: 122
diff changeset
  1873
    (key == #FindNext) ifTrue:[^self].
claus
parents: 122
diff changeset
  1874
    (key == #FindPrev) ifTrue:[^self].
claus
parents: 122
diff changeset
  1875
    (key == #GotoLine) ifTrue:[^self].
claus
parents: 122
diff changeset
  1876
    "
claus
parents: 122
diff changeset
  1877
     a normal key - let superclass's method insert it
claus
parents: 122
diff changeset
  1878
    "
claus
parents: 122
diff changeset
  1879
    super keyPress:key x:x y:y.
claus
parents: 122
diff changeset
  1880
claus
parents: 122
diff changeset
  1881
    "
claus
parents: 122
diff changeset
  1882
     for end-of-text, also move to end-of-line
claus
parents: 122
diff changeset
  1883
    "
claus
parents: 122
diff changeset
  1884
    key == #EndOfText ifTrue:[
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1885
        super keyPress:#EndOfLine x:x y:y.
125
claus
parents: 122
diff changeset
  1886
    ].
6136
54e34fbf8f6d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6117
diff changeset
  1887
    
54e34fbf8f6d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6117
diff changeset
  1888
    key isCharacter ifTrue:[
54e34fbf8f6d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6117
diff changeset
  1889
        self resizeOrScroll.
54e34fbf8f6d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6117
diff changeset
  1890
    ].
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1891
6209
5e83ab74283d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6195
diff changeset
  1892
    "Modified: / 27-09-2017 / 15:34:19 / cg"
6305
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  1893
    "Modified: / 18-04-2018 / 11:47:58 / stefan"
6389
93eb877ae6f7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6305
diff changeset
  1894
    "Modified: / 09-08-2018 / 09:29:52 / Claus Gittinger"
6392
22ceac28ebca #BUGFIX by Maren
matilk
parents: 6389
diff changeset
  1895
    "Modified: / 13-08-2018 / 12:18:59 / Maren"
6516
1df1200a6040 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6512
diff changeset
  1896
    "Modified: / 07-01-2019 / 18:14:08 / Stefan Vogel"
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1897
!
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1898
6253
b9ef37074e3b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6233
diff changeset
  1899
keyboardZoom:largerBoolean
6254
52f64117b8f3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6253
diff changeset
  1900
    "CTRL+/- zoom action"
52f64117b8f3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6253
diff changeset
  1901
5929
ea7162cefcc5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5910
diff changeset
  1902
    "/ ignored here
ea7162cefcc5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5910
diff changeset
  1903
!
ea7162cefcc5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5910
diff changeset
  1904
1936
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1905
pointerLeave:state
1937
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
  1906
    (acceptOnPointerLeave and:[enabled and:[self modified]]) ifTrue:[
1936
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1907
        self accept
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1908
    ].
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1909
    super pointerLeave:state
1937
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
  1910
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
  1911
    "Modified: / 28.6.1999 / 18:08:29 / cg"
1936
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1912
!
f8253741114d pointerLeave fixed
tm
parents: 1918
diff changeset
  1913
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1914
resizeOrScroll
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1915
    "helper for keyPress.
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1916
     Extracted for easier subclass redefinition."
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1917
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1918
    |xCol newOffset newWidth|
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1919
125
claus
parents: 122
diff changeset
  1920
    newWidth := self widthOfContents.
claus
parents: 122
diff changeset
  1921
claus
parents: 122
diff changeset
  1922
    "
claus
parents: 122
diff changeset
  1923
     should (& can) we resize ?
claus
parents: 122
diff changeset
  1924
    "
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1925
    xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x.
6139
8c85b22e8722 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6136
diff changeset
  1926
    (xCol > (width - 50 "* (5/6)")) ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1927
        self changedPreferredBounds:nil
125
claus
parents: 122
diff changeset
  1928
    ] ifFalse:[
6139
8c85b22e8722 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6136
diff changeset
  1929
"/ Do not shrink!! Enterbox grows if size of contained Editfield changes!!    
8c85b22e8722 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6136
diff changeset
  1930
"/        newWidth < (width * (1/3)) ifTrue:[
8c85b22e8722 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6136
diff changeset
  1931
"/            self changedPreferredBounds:nil
8c85b22e8722 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6136
diff changeset
  1932
"/        ]
125
claus
parents: 122
diff changeset
  1933
    ].
claus
parents: 122
diff changeset
  1934
290
f539121393b1 innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents: 279
diff changeset
  1935
    autoScrollHorizontally ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1936
        "
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1937
         did someone react (i.e. has my extent changed) ?
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1938
         (if not, we scroll horizontally)
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1939
        "
2016
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  1940
        lengthLimit notNil ifTrue:[
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  1941
            (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
  1942
            ifTrue:[
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  1943
                ^ self
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  1944
            ].
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  1945
        ].
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  1946
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1947
        xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x.
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1948
        (xCol > (width * (5/6))) ifTrue:[
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1949
            newOffset := viewOrigin x + (width // 2).
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1950
        ] ifFalse:[
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1951
            (xCol < (width * (1/6))) ifTrue:[
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1952
                newOffset := 0 max: viewOrigin x - (width // 2).
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1953
            ] ifFalse:[
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1954
                newOffset := viewOrigin x
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1955
            ]
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1956
        ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1957
        newOffset ~~ viewOrigin x ifTrue:[
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1958
            self scrollHorizontalTo:newOffset.
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1959
        ]
125
claus
parents: 122
diff changeset
  1960
    ].
1103
0efbd1ac68f4 use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
  1961
6136
54e34fbf8f6d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6117
diff changeset
  1962
    "Modified: / 15-03-2017 / 19:22:56 / cg"
6139
8c85b22e8722 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6136
diff changeset
  1963
    "Modified: / 30-03-2017 / 18:46:50 / stefan"
8c85b22e8722 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6136
diff changeset
  1964
    "Modified (format): / 30-03-2017 / 22:24:58 / stefan"
316
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1965
!
1e27aa926710 fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1966
784
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1967
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
  1968
    "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
  1969
1282
781c5d134e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
  1970
    |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
  1971
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  1972
    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
  1973
        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
  1974
        (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
  1975
            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
  1976
        ].
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1977
    ].
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1978
    self makeCursorVisible.
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1979
    super sizeChanged:how.
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  1980
    self computeTopMargin.
6811
a9e9675aca68 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6809
diff changeset
  1981
    self invalidate.
784
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1982
4161490a4b6d scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
  1983
    "Modified: 10.7.1996 / 10:59:37 / cg"
4986
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1984
!
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1985
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1986
tripleClickX:x y:y
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1987
    "triple-click - select all"
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1988
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1989
    self selectAll
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1990
f3349579b8d3 Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4979
diff changeset
  1991
    "Created: / 09-04-2014 / 19:04:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1992
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  1993
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1994
!EditField methodsFor:'focus handling'!
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1995
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1996
hasKeyboardFocus:aBoolean
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1997
    "the view got/lost the keyboard focus"
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  1998
4930
af079679defd class: EditField
Stefan Vogel <sv@exept.de>
parents: 4910
diff changeset
  1999
    |hadKeyboardFocus|
af079679defd class: EditField
Stefan Vogel <sv@exept.de>
parents: 4910
diff changeset
  2000
af079679defd class: EditField
Stefan Vogel <sv@exept.de>
parents: 4910
diff changeset
  2001
    hadKeyboardFocus := hasKeyboardFocus.
af079679defd class: EditField
Stefan Vogel <sv@exept.de>
parents: 4910
diff changeset
  2002
    super hasKeyboardFocus:aBoolean.
af079679defd class: EditField
Stefan Vogel <sv@exept.de>
parents: 4910
diff changeset
  2003
af079679defd class: EditField
Stefan Vogel <sv@exept.de>
parents: 4910
diff changeset
  2004
    (acceptOnLostFocus and:[enabled and:[aBoolean not and:[hadKeyboardFocus]]]) ifTrue:[
6113
8731509a4171 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6095
diff changeset
  2005
        (model notNil and:[model value = self argForChangeMessage]) ifTrue:[
8731509a4171 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6095
diff changeset
  2006
            ^ self
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2007
        ].
4930
af079679defd class: EditField
Stefan Vogel <sv@exept.de>
parents: 4910
diff changeset
  2008
        self accept.
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2009
    ].
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2010
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2011
    "Created: / 11.12.1996 / 16:57:50 / cg"
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2012
    "Modified: / 6.12.1997 / 14:07:12 / cg"
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2013
!
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2014
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2015
showFocus:explicit
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2016
    "the view got the keyboard focus 
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2017
     (either explicit, via tabbing; or implicit, by pointer movement)
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2018
      - change any display attributes as req'd."
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2019
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2020
    "/ giving me the focus is like clicking on me
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2021
    "/ (tell my enterFieldGroup ...)
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2022
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2023
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2024
    (enabled or:[explicit]) ifTrue:[
5240
331c5840649e class: EditField
Claus Gittinger <cg@exept.de>
parents: 5122
diff changeset
  2025
        super showFocus:explicit.
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2026
        clickAction notNil ifTrue:[clickAction value:self].
3461
0b3cc6fc00ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3460
diff changeset
  2027
        "/ mhmh - should we ALWAYS do this ?
5240
331c5840649e class: EditField
Claus Gittinger <cg@exept.de>
parents: 5122
diff changeset
  2028
        true "explicit" ifTrue:[ self makeCursorVisible ].
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2029
    ]
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2030
3461
0b3cc6fc00ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3460
diff changeset
  2031
    "Modified: / 06-03-2007 / 21:11:17 / cg"
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2032
!
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2033
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2034
showNoFocus:explicit
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2035
    "the view lost the keyboard focus 
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2036
     (either explicit, via tabbing; or implicit, by pointer movement)
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2037
      - change any display attributes as req'd."
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2038
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2039
    self hideCursor.
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2040
    super showNoFocus:explicit
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2041
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2042
    "Modified: / 17.9.1998 / 15:10:04 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  2043
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  2044
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  2045
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  2046
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  2047
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1912
diff changeset
  2048
4992
7d8b66d3c846 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4991
diff changeset
  2049
    ^ UserPreferences current focusFollowsMouse ~~ false
7d8b66d3c846 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4991
diff changeset
  2050
         and:[(styleSheet at:#'editField.requestFocusOnPointerEnter' default:true)
7d8b66d3c846 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4991
diff changeset
  2051
         and:[self enabled 
7d8b66d3c846 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4991
diff changeset
  2052
         and:[self isReadOnly not]]]
1806
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2053
! !
fe6269361661 comment & category change
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
  2054
5484
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2055
!EditField methodsFor:'help'!
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2056
6255
d046305c2760 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6254
diff changeset
  2057
helpTextAt:aPoint
5484
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2058
    |len|
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2059
    
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2060
    len := self widthOfContents.
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2061
    len > width ifTrue:[
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2062
        ^ self contents  
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2063
    ].
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2064
    ^ nil
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2065
! !
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2066
2750
94531b6049a3 method category rename
Claus Gittinger <cg@exept.de>
parents: 2737
diff changeset
  2067
!EditField methodsFor:'initialization & release'!
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2068
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2069
computeTopMargin
5043
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2070
    |innerHeight rest font fontHeight fontDescent|
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2071
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2072
    innerHeight := self innerHeight.
6442
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2073
    innerHeight <= 0 ifTrue:[ 
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2074
        "/ textStartTop := 2.
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2075
        topMargin := textStartTop := 2.
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2076
        ^ self 
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2077
    ].
5044
db43a967ff95 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5043
diff changeset
  2078
5043
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2079
    font := gc font.
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2080
    fontHeight := font height.
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2081
    fontDescent := font descent.
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2082
    rest := innerHeight - (fontHeight + (fontDescent // 2)).
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2083
    rest > 1 ifTrue:[
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2084
        textStartTop := (rest // 2) + margin + topMargin
5043
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2085
    ] ifFalse:[
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2086
        "/ care if font is too high for my height: 
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2087
        "/ shift baseline towards the top, so that the same is cut off at both ends.
7faaf3204fc3 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5042
diff changeset
  2088
        "/ (the heuristic fontDescent//3) gives a few pixels more at the top)
6442
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2089
        textStartTop := (fontDescent//3) - ((font ascent + fontDescent - innerHeight) // 2).
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2090
        textStartTop := textStartTop max:2.
5044
db43a967ff95 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5043
diff changeset
  2091
    ].
6442
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2092
fe1087b94999 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6392
diff changeset
  2093
    "Modified: / 24-09-2018 / 22:12:31 / Claus Gittinger"
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2094
!
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2095
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2096
initStyle
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  2097
    "setup viewStyle specifics"
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  2098
3265
33baaef82ef3 resource directive
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
  2099
    <resource: #style (#'editField.cursorType'
33baaef82ef3 resource directive
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
  2100
                       #'editField.cursorForegroundColor' 
4013
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2101
                       #'editField.cursorBackgroundColor'
3265
33baaef82ef3 resource directive
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
  2102
                       )>
33baaef82ef3 resource directive
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
  2103
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2104
    super initStyle.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2105
4989
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2106
    self computeTopMargin.
cb0fb182dc2c class: EditField
Claus Gittinger <cg@exept.de>
parents: 4986
diff changeset
  2107
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2108
    DefaultBackgroundColor notNil ifTrue:[
5642
0f8102c3091d device access
Claus Gittinger <cg@exept.de>
parents: 5594
diff changeset
  2109
        bgColor := DefaultBackgroundColor onDevice:device.
1482
19c10a4142bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2110
"/        bgColor ditherForm notNil ifTrue:[
4896
b0ed9d5390d3 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4888
diff changeset
  2111
"/            bgColor := (bgColor copy) exactOrNearestOn:self graphicsDevice
1482
19c10a4142bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1478
diff changeset
  2112
"/        ].
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  2113
        self viewBackground:bgColor.
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2114
    ].
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2115
    fgColor := DefaultForegroundColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2116
    selectionFgColor := DefaultSelectionForegroundColor.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2117
    selectionBgColor := DefaultSelectionBackgroundColor.
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
  2118
1544
bb7e168dd651 dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2119
    "/ enable this, when the focus detection works correctly (in dialogs)
1848
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  2120
    cursorTypeNoFocus := #none.
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  2121
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  2122
    cursorType := styleSheet at:#'editField.cursorType' default:cursorType.
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  2123
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  2124
    cursorFgColor := styleSheet at:#'editField.cursorForegroundColor' default:cursorFgColor.
fee9c6718e70 new cursorType: Ibeam
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  2125
    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
  2126
4013
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2127
    DefaultLevel notNil ifTrue:[
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2128
        self level:DefaultLevel.
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2129
    ].
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2130
    DefaultBorderWidth notNil ifTrue:[
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2131
        self borderWidth:DefaultBorderWidth.
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2132
        DefaultBorderColor notNil ifTrue:[
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2133
            self borderColor:DefaultBorderColor.
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2134
        ].
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2135
    ].
3ed9d93e8ff6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3991
diff changeset
  2136
4320
088ca53d23ad comment/format in: #initStyle
az
parents: 4214
diff changeset
  2137
    "Modified: / 21-05-1998 / 15:38:14 / cg"
088ca53d23ad comment/format in: #initStyle
az
parents: 4214
diff changeset
  2138
    "Modified (comment): / 05-10-2011 / 15:51:15 / az"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2139
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2140
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2141
initialize
5910
83afa19a39f7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5815
diff changeset
  2142
    |font|
83afa19a39f7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5815
diff changeset
  2143
    
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2144
    super initialize.
5910
83afa19a39f7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5815
diff changeset
  2145
    font := gc font.
83afa19a39f7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5815
diff changeset
  2146
    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
  2147
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2148
    nFullLinesShown := 1.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2149
    nLinesShown := 1.
1225
6220d3bd3033 initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  2150
    trimBlankLines := immediateAccept := acceptOnLostFocus := false.
1937
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
  2151
    acceptOnPointerLeave := false.
1225
6220d3bd3033 initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
  2152
    enabled := fixedSize := autoScrollHorizontally := true.
298
932fa5ca44f8 added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents: 290
diff changeset
  2153
    acceptOnLeave := acceptOnReturn := acceptOnTab := true.
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2154
    cursorShown := true.
978
6e678fdc6e5b allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  2155
    entryCompletionCharacter := #Tab.
2105
364c74512645 neu: acceptIfUnchanged
ca
parents: 2042
diff changeset
  2156
    acceptIfUnchanged := false.
673
e5a4bcfc960e use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents: 667
diff changeset
  2157
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2158
    leaveKeys isNil ifTrue:[
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2159
        leaveKeys := self class defaultLeaveKeys.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2160
    ].
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2161
    cursorMovementWhenUpdating := #endOfLine
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  2162
1937
b88111019826 added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
  2163
    "Modified: / 28.6.1999 / 18:08:17 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2164
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2165
3702
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2166
!EditField methodsFor:'menu actions'!
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2167
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2168
editMenu
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2169
    "return a popUpMenu for the receiver"
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2170
6478
589bfe2de985 #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6453
diff changeset
  2171
    <resource: #keyboard ( #Accept #Copy #Cut #Paste #PasteFromHistory #OpenSpecialCharacterWindow) >
3702
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2172
    <resource: #programMenu>
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2173
4212
8b3a3ef8278a changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  2174
    |items m isReadOnly|
8b3a3ef8278a changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  2175
8b3a3ef8278a changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  2176
    isReadOnly := (self isReadOnly == true or:[enabled == false]).
8b3a3ef8278a changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  2177
    isReadOnly ifTrue:[
3702
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2178
        items := #(
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2179
                ('Copy'   copySelection  Copy  )
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2180
                )
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2181
    ] ifFalse:[
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2182
        items := #(
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2183
                    ('Cut'    cut            Cut   )
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2184
                    ('Copy'   copySelection  Copy  )
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2185
                    ('Paste'  pasteOrReplace Paste )
6478
589bfe2de985 #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6453
diff changeset
  2186
                    ('Paste...'  pasteOrReplaceFromHistory PasteFromHistory )
3702
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2187
                   ).
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2188
        (acceptAction notNil 
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2189
        or:[model notNil and:[changeMsg notNil]]) ifTrue:[
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2190
            immediateAccept ifFalse:[
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2191
                items := items , #(
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2192
                                        ('-'                     )
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2193
                                        ('Accept'  accept  Accept)
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2194
                                    ).
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2195
            ].
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2196
        ].
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2197
    ].
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2198
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2199
    passwordCharacter notNil ifTrue:[
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2200
        items := items ,
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2201
                    #(
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2202
                        ('-'                     )
6725
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2203
                        ('Show Text'                showPasswordCharacters )
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2204
                    ).
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2205
    ] ifFalse:[
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2206
        items := items ,
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2207
                    #(
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2208
                        ('-'                     )
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2209
                        ('Hide as Password'                hideAsPassword )
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2210
                    ).
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2211
    ].    
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2212
4992
7d8b66d3c846 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4991
diff changeset
  2213
    isReadOnly ifFalse:[
4194
87d816906093 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4157
diff changeset
  2214
        items := items ,
87d816906093 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4157
diff changeset
  2215
                    #(
87d816906093 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4157
diff changeset
  2216
                        ('-'                     )
4938
136d6382e549 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
  2217
                        ('Insert Unicode...'            insertUnicode )
4194
87d816906093 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4157
diff changeset
  2218
                    ).
4938
136d6382e549 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
  2219
        CharacterSetView notNil ifTrue:[
136d6382e549 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
  2220
            items := items ,
136d6382e549 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
  2221
                        #(
136d6382e549 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
  2222
                            ('Special Characters...'    specialCharacters  OpenSpecialCharacterWindow )
136d6382e549 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
  2223
                        ).
136d6382e549 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4930
diff changeset
  2224
        ].
4194
87d816906093 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4157
diff changeset
  2225
    ].
87d816906093 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4157
diff changeset
  2226
6725
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2227
    self contents asFilename exists ifTrue:[
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2228
        items := items ,
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2229
                    #(
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2230
                        ('-'                     )
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2231
                        ('Show in File Browser'                openFileBrowser )
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2232
                    ).
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2233
    ] ifFalse:[
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2234
        self contents asFilename directory exists ifTrue:[
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2235
            items := items ,
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2236
                        #(
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2237
                            ('-'                     )
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2238
                            ('Show Directory in File Browser'                openFileBrowser )
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2239
                        ).
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2240
        ]
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2241
    ].
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2242
3702
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2243
    m := PopUpMenu itemList:items resources:resources.
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2244
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2245
    passwordCharacter notNil ifTrue:[
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2246
        m disable:#copySelection
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2247
    ].
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2248
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2249
    self hasSelectionForCopy ifFalse:[
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2250
        m disable:#copySelection
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2251
    ].
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2252
    self hasSelection ifFalse:[
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2253
        m disable:#cut
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2254
    ].
4212
8b3a3ef8278a changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  2255
    isReadOnly ifTrue:[
3702
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2256
        m disableAll:#(cut pasteOrReplace accept)
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2257
    ].
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2258
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2259
    ^ m
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2260
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2261
    "Modified: / 17-08-2017 / 00:11:36 / cg"
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2262
!
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2263
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2264
hideAsPassword
6725
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2265
    "hide passwords (i.e. turn on password mode)"
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2266
6724
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2267
    |id|
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2268
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2269
    passwordCharacter := $*.
6724
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2270
    self invalidate.
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2271
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2272
    "/ remember to come up with password character the next time
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2273
    FieldsHiddenAsPassword isNil ifTrue:[
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2274
        FieldsHiddenAsPassword := Set new.
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2275
    ].
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2276
    (id := self automationUUID) isNil ifTrue:[
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2277
        id := self fullXPath.
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2278
    ].
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2279
    FieldsHiddenAsPassword add:id.
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2280
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2281
    "Created: / 17-08-2017 / 00:11:41 / cg"
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2282
!
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2283
6725
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2284
openFileBrowser
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2285
    |fn|
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2286
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2287
    fn := self contents asFilename.
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2288
    fn exists ifFalse:[
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2289
        fn := fn directory.
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2290
    ].
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2291
    FileBrowser default openOn:fn
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2292
!
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2293
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2294
showPasswordCharacters
6725
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2295
    "show the plain text (i.e. turn off password mode)"
48ab339411d2 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6724
diff changeset
  2296
6724
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2297
    |id|
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2298
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2299
    passwordCharacter := nil.
6724
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2300
    self invalidate.
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2301
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2302
    FieldsHiddenAsPassword notNil ifTrue:[
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2303
        (id := self automationUUID) isNil ifTrue:[
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2304
            id := self fullXPath.
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2305
        ].
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2306
        "/ forget
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2307
        FieldsHiddenAsPassword remove:id ifAbsent:nil.
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2308
    ].
6190
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2309
5cbc34a6f2d0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2310
    "Created: / 17-08-2017 / 00:11:27 / cg"
3702
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2311
! !
30f5a2efe531 changed #editMenu
Claus Gittinger <cg@exept.de>
parents: 3648
diff changeset
  2312
5122
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2313
!EditField methodsFor:'native widget support'!
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2314
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2315
nativeWindowType
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2316
    "return a symbol describing my native window type 
5542
2b73601f4549 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2317
     (may be used internally by the device as a native window creation hint,
2b73601f4549 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5484
diff changeset
  2318
      if the device supports native windows)"
5122
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2319
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2320
    ^ #EditField
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2321
! !
d2cf0e4081f0 class: EditField
Claus Gittinger <cg@exept.de>
parents: 5098
diff changeset
  2322
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2323
!EditField methodsFor:'private'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2324
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2325
argForChangeMessage
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2326
    "redefined to send use converted value (if I have one)"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2327
2538
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2328
    |str|
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2329
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2330
    str := self editValue.
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2331
    (acceptIfUnchanged
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2332
    and:[model notNil
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2333
    and:[model value == self editValue]]) ifTrue:[
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2334
        "/ copy to force valueHolder to trigger
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2335
        str := str copy.
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2336
    ].
ce313a0572e7 care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
  2337
    ^ str
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2338
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2339
6305
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2340
doCompletion
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2341
    |oldContents newContents|
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2342
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2343
    self entryCompletionBlock isNil ifTrue:[
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2344
        ^ self.
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2345
    ].
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2346
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2347
    oldContents := self contents.
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2348
    oldContents isNil ifTrue:[
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2349
        oldContents := ''
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2350
    ] ifFalse:[
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2351
        oldContents := oldContents asString
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2352
    ].
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2353
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2354
    self entryCompletionBlock valueWithOptionalArgument:oldContents and:self.
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2355
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2356
    newContents := self contents.
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2357
    newContents isNil ifTrue:[
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2358
        newContents := ''
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2359
    ] ifFalse:[
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2360
        newContents := newContents asString
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2361
    ].
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2362
    newContents ~= oldContents ifTrue:[
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2363
        self textChanged
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2364
    ].
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2365
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2366
    "Created: / 18-04-2018 / 11:46:17 / stefan"
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2367
!
5e9740739ad1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6268
diff changeset
  2368
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2369
getListFromModel
5777
d278c2f170c3 #OTHER by mawalch
mawalch
parents: 5725
diff changeset
  2370
    "redefined to acquire the text via the aspectMsg - not the listMsg,
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2371
     and to ignore updates resulting from my own change."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2372
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2373
    |val|
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2374
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2375
    (model notNil and:[aspectMsg notNil]) ifTrue:[
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2376
        aspectMsg == #value ifTrue:[
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2377
            val := model value
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2378
        ] ifFalse:[
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2379
            val := model perform:aspectMsg
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2380
        ].
1503
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2381
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2382
        "
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2383
         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
  2384
        "
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2385
        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
  2386
            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
  2387
            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
  2388
                ^ self
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2389
            ]
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2390
        ].
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2391
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2392
        self editValue:val.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2393
    ]
1464
079d8a07b19c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1407
diff changeset
  2394
1503
ae953a367422 care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents: 1482
diff changeset
  2395
    "Modified: / 23.4.1998 / 10:10:37 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2396
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2397
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2398
startAutoScrollDown:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2399
    "no vertical scrolling in editfields"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2400
5095
a65fea7e7c4b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5055
diff changeset
  2401
    ^ false
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2402
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2403
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2404
startAutoScrollUp:y
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2405
    "no vertical scrolling in editfields"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2406
5095
a65fea7e7c4b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5055
diff changeset
  2407
    ^ false
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2408
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2409
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2410
textChanged
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2411
    "this is sent by mySelf (somewhere in a superclass) whenever
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2412
     my contents has changed. 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2413
     A good place to add immediateAccept functionality and check for the
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2414
     lengthLimit."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2415
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2416
    |string c|
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2417
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2418
    super textChanged.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2419
    string := self contents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2420
    lengthLimit notNil ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2421
	string size > lengthLimit ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2422
	    c := cursorCol.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2423
	    self contents:(string copyTo:lengthLimit).
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2424
	    self flash.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2425
	    self cursorCol:c.
125
claus
parents: 122
diff changeset
  2426
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2427
    ].
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2428
    immediateAccept ifTrue:[
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2429
	self accept
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2430
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2431
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2432
2616
dc97ec169256 type on method name
Claus Gittinger <cg@exept.de>
parents: 2538
diff changeset
  2433
textChangedButNoSizeChange
2296
b924cc94580c immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
  2434
    "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
  2435
     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
  2436
     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
  2437
2616
dc97ec169256 type on method name
Claus Gittinger <cg@exept.de>
parents: 2538
diff changeset
  2438
    super textChangedButNoSizeChange.
2296
b924cc94580c immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
  2439
    immediateAccept ifTrue:[
b924cc94580c immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
  2440
        self accept
b924cc94580c immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
  2441
    ]
b924cc94580c immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
  2442
!
b924cc94580c immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
  2443
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  2444
updateBackground
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  2445
    "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
  2446
1974
c513cc45de3a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  2447
    |fg|
c513cc45de3a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  2448
3648
7a959d9db34f dont (re)set the background, if I have a bg-channel.
Claus Gittinger <cg@exept.de>
parents: 3585
diff changeset
  2449
    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
  2450
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1683
diff changeset
  2451
    (self isReadOnly or:[enabled not]) ifTrue:[
1632
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  2452
        self backgroundColor:(View defaultViewBackgroundColor).
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  2453
        enabled ifFalse:[
1974
c513cc45de3a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  2454
            fg := StyleSheet colorAt:'editField.disabledForegroundColor' default:nil.
c513cc45de3a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  2455
            fg isNil ifTrue:[
c513cc45de3a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  2456
                fg := StyleSheet colorAt:'button.disabledForegroundColor' default:Color gray.
c513cc45de3a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  2457
            ].
c513cc45de3a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
  2458
            self foregroundColor:fg.
3408
df7db0818a22 #updateBackground bug fixed
sr
parents: 3367
diff changeset
  2459
        ] ifTrue:[
df7db0818a22 #updateBackground bug fixed
sr
parents: 3367
diff changeset
  2460
            self foregroundColor:DefaultForegroundColor.
df7db0818a22 #updateBackground bug fixed
sr
parents: 3367
diff changeset
  2461
        ].
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  2462
    ] ifFalse:[
1632
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  2463
        self backgroundColor:DefaultBackgroundColor.
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  2464
        self foregroundColor:DefaultForegroundColor.
1631
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  2465
    ]
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  2466
1632
01a7b330622a change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents: 1631
diff changeset
  2467
    "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
  2468
!
f8fae6670540 change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  2469
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2470
visibleAt:visLineNr
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2471
    "return the string at lineNr for display.
6809
1962a5ee3a4e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6725
diff changeset
  2472
     If there is a password character, return a string consisting of those only.
1962a5ee3a4e #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6725
diff changeset
  2473
     visLineNr is a visible lineNr (i.e. not the absolute lineNr)"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2474
3988
7b496d3c7d12 changed: #visibleAt:
Claus Gittinger <cg@exept.de>
parents: 3987
diff changeset
  2475
    |s emptyText|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2476
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2477
    s := super visibleAt:visLineNr.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2478
    passwordCharacter notNil ifTrue:[
3985
31fa420f210a +emptyFieldReplacementText
Claus Gittinger <cg@exept.de>
parents: 3975
diff changeset
  2479
        ^ String new:(s size) withAll:passwordCharacter
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2480
    ].
3985
31fa420f210a +emptyFieldReplacementText
Claus Gittinger <cg@exept.de>
parents: 3975
diff changeset
  2481
    (s isEmptyOrNil  
3988
7b496d3c7d12 changed: #visibleAt:
Claus Gittinger <cg@exept.de>
parents: 3987
diff changeset
  2482
    and:[ (emptyText := self emptyFieldReplacementText) notNil  
3985
31fa420f210a +emptyFieldReplacementText
Claus Gittinger <cg@exept.de>
parents: 3975
diff changeset
  2483
    and:[ self hasFocus not 
31fa420f210a +emptyFieldReplacementText
Claus Gittinger <cg@exept.de>
parents: 3975
diff changeset
  2484
    and:[ visLineNr == 1 ]]])
31fa420f210a +emptyFieldReplacementText
Claus Gittinger <cg@exept.de>
parents: 3975
diff changeset
  2485
    ifTrue:[
5725
36a040e8555b #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  2486
        ^ emptyText allItalic withColor:Color lightGray.
3985
31fa420f210a +emptyFieldReplacementText
Claus Gittinger <cg@exept.de>
parents: 3975
diff changeset
  2487
    ].
31fa420f210a +emptyFieldReplacementText
Claus Gittinger <cg@exept.de>
parents: 3975
diff changeset
  2488
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2489
    ^ s
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2490
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2491
    "Modified: 6.9.1995 / 12:25:06 / claus"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2492
! !
125
claus
parents: 122
diff changeset
  2493
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2494
!EditField methodsFor:'queries'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2495
6489
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2496
computePreferredExtent
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2497
    "return the preferred extent of this view.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2498
     That is the width of the string plus some extra, 
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2499
     but not wider than half of the screen"
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2500
1120
3faa7fc84bad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2501
    |string w h f|
125
claus
parents: 122
diff changeset
  2502
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2503
    string := self contents.
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2504
    (string isNil or:[string isBlank]) ifTrue:[
4086
677dab361ea7 changed: #preferredExtent
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
  2505
        w := fontWidth * 20.  "space for 20 characters"
677dab361ea7 changed: #preferredExtent
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
  2506
    ] ifFalse:[
677dab361ea7 changed: #preferredExtent
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
  2507
        "length of current contents +  50% space to type more characters"
5815
a041a7f7b30b #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5777
diff changeset
  2508
        f := gc deviceFont.
4086
677dab361ea7 changed: #preferredExtent
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
  2509
        w := ((f widthOf:string) * 1.5) rounded. 
677dab361ea7 changed: #preferredExtent
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
  2510
        w := w + margin + margin.
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2511
    ].
6136
54e34fbf8f6d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6117
diff changeset
  2512
    "/ never more than the screen width, minus some 
54e34fbf8f6d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6117
diff changeset
  2513
    w := w min:(device width - 200 " // 2").
667
d02f6bba8fc5 use fonts maxHeight in prefExtent (A-Umlaut)
Claus Gittinger <cg@exept.de>
parents: 660
diff changeset
  2514
3929
3c88a4e7a7ac preferredExtent fontHeight
fm
parents: 3797
diff changeset
  2515
    "/ h := f maxHeight + (f maxDescent * 2) + (margin * 2).
4086
677dab361ea7 changed: #preferredExtent
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
  2516
    h := fontHeight + topMargin + (margin * 2).
1120
3faa7fc84bad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2517
3faa7fc84bad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2518
    ^ w rounded @ h rounded
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2519
6489
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2520
    "Created: / 09-11-2018 / 19:51:43 / Claus Gittinger"
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2521
!
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2522
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2523
hasSelectionForCopy
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2524
    "return true, if there is a selection which can be copied."
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2525
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2526
    ^ passwordCharacter isNil and:[self hasSelection]
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2527
!
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2528
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2529
isInputField
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2530
    "return true, if the receiver is some kind of input view,
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2531
     i.e. it should (can) be part of an enterGroup.
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2532
     Return true here"
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2533
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2534
    ^ true
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2535
6afea8177a52 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6478
diff changeset
  2536
    "Created: 4.3.1996 / 11:32:34 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2537
!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2538
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2539
specClass
1372
c32cb309da8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  2540
    "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
  2541
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2542
    self class == EditField ifTrue:[^ InputFieldSpec].
1047
4d7bc9784f94 specClass query
ca
parents: 1034
diff changeset
  2543
    ^ super specClass
125
claus
parents: 122
diff changeset
  2544
1372
c32cb309da8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  2545
    "Modified: / 5.9.1995 / 17:28:27 / claus"
c32cb309da8d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  2546
    "Modified: / 31.10.1997 / 19:48:59 / cg"
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2547
!
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2548
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2549
tabMeansNextField
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2550
    "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
  2551
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2552
    "if I have a completionBlock, I want my Tabs ..."
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2553
2993
5a610fe081ed entryCompletionBlockHolder
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  2554
    ^ self entryCompletionBlock isNil or:[entryCompletionCharacter ~~ #Tab]
325
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2555
87e24beaf835 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2556
    "Created: 7.2.1996 / 19:16:38 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2557
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2558
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2559
!EditField methodsFor:'realization'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2560
1274
a861b526e2c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
  2561
realize
6724
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2562
    "redefined to scroll back to beginning when realized,
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2563
     and also to init the password character if the user applied
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2564
     hideAsPassword the last time on a field like me."
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2565
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2566
    |id|
1268
da86fb7a9f12 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  2567
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  2568
    viewOrigin := 0 @ viewOrigin y.
6724
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2569
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2570
    "/ did user configure me the last time to use password character?
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2571
    FieldsHiddenAsPassword notNil ifTrue:[
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2572
        (id := self automationUUID) isNil ifTrue:[
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2573
            id := self fullXPath.
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2574
        ].
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2575
        (FieldsHiddenAsPassword includes:id) ifTrue:[
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2576
            passwordCharacter := $*
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2577
        ].
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2578
    ].
0185a3113b0d #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6708
diff changeset
  2579
    super realize.
1268
da86fb7a9f12 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
  2580
1274
a861b526e2c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
  2581
    "Created: 24.7.1997 / 18:23:15 / cg"
125
claus
parents: 122
diff changeset
  2582
! !
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2583
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2584
!EditField methodsFor:'scrolling'!
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2585
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2586
makeColVisible:col inLine:lineNr
6095
65ed08296dcb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5973
diff changeset
  2587
    "don't scroll for the cursor, if it's beyond the text and a lengthLimit
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2588
     is present."
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2589
2759
c7cdd64a930f makeCursorVisible-fix
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
  2590
    |wText innerWidth colToMakeVisible|
2424
aa7b253717b1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2591
aa7b253717b1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2592
    innerWidth := self innerWidth.
2759
c7cdd64a930f makeCursorVisible-fix
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
  2593
    colToMakeVisible := col.
2016
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  2594
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  2595
    lengthLimit notNil ifTrue:[
6222
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2596
        (self xOfCol:col-1 inVisibleLine:1) < self viewOrigin x ifTrue:[
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2597
        ] ifFalse:[    
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2598
            (self xOfCol:lengthLimit inVisibleLine:1) <= innerWidth
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2599
            ifTrue:[
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2600
                ^ self
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2601
            ].
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2602
            (self xOfCol:col inVisibleLine:1) <= innerWidth
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2603
            ifTrue:[
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2604
                ^ self
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2605
            ].
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2606
            (col == cursorCol and:[col > lengthLimit]) ifTrue:[
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2607
                colToMakeVisible := lengthLimit
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2608
            ].
2016
7a4d89c99c98 dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents: 1999
diff changeset
  2609
        ].
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2610
    ].
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2611
2759
c7cdd64a930f makeCursorVisible-fix
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
  2612
    super makeColVisible:colToMakeVisible inLine:lineNr.
c7cdd64a930f makeCursorVisible-fix
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
  2613
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2614
    "/ new:
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2615
    "/ care to make the most possible visible
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2425
diff changeset
  2616
    viewOrigin x > 0 ifTrue:[
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2617
        wText := self widthOfLine:lineNr.
6209
5e83ab74283d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6195
diff changeset
  2618
        wText < (innerWidth-10) ifTrue:[
1751
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2619
            self scrollHorizontalTo:0
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2620
        ]
f29c3312beaf adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents: 1733
diff changeset
  2621
    ]
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2622
4157
7f2928f99268 comment/format in: #makeColVisible:inLine:
Claus Gittinger <cg@exept.de>
parents: 4118
diff changeset
  2623
    "Modified: / 06-09-1995 / 13:57:53 / claus"
6222
b5ed5993de3e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6209
diff changeset
  2624
    "Modified: / 23-10-2017 / 18:32:34 / cg"
192
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2625
! !
fc2fc4347d5d checkin from Browser
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
  2626
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2627
!EditField methodsFor:'selections'!
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2628
3366
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2629
copySelection
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2630
    "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
  2631
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2632
    passwordCharacter notNil ifTrue:[
6268
3d8b11c7df18 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6255
diff changeset
  2633
        self beepInEditor.
3366
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2634
        ^ self
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2635
    ].
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2636
    ^ super copySelection
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2637
!
0df1eb5da5aa refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents: 3305
diff changeset
  2638
1080
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2639
selectAll
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2640
    "select the whole text.
5594
09e1ac49efce #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5542
diff changeset
  2641
     redefined to send super selectFrom... since we don't want the
1080
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2642
     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
  2643
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2644
    |len|
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2645
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2646
    list isNil ifTrue:[
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2647
        self unselect
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2648
    ] ifFalse:[
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2649
        len := (self listAt:1) size.
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2650
        len ~~ 0 ifTrue:[
4992
7d8b66d3c846 class: EditField
Stefan Vogel <sv@exept.de>
parents: 4991
diff changeset
  2651
            self selectFromLine:1 col:1 toLine:1 col:len.
1080
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2652
        ].
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2653
        typeOfSelection := nil
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2654
    ]
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2655
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2656
    "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
  2657
!
73877901fa7d redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  2658
4540
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2659
selectFrom:firstColToSelect
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2660
    "select the right part of the text"
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2661
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2662
    |len|
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2663
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2664
    list isNil ifTrue:[
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2665
        self unselect
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2666
    ] ifFalse:[
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2667
        len := (self listAt:1) size.
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2668
        firstColToSelect <= len ifTrue:[
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2669
            self selectFromLine:1 col:firstColToSelect toLine:1 col:len.
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2670
        ].
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2671
        typeOfSelection := nil
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2672
    ]
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2673
!
ca28a8145610 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4507
diff changeset
  2674
5973
7e1d3c8aa4ad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5929
diff changeset
  2675
setClipboardText:aString
5041
18f2861653bb class: EditField
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  2676
    "redefined to refuse to copy the password to the clipboard"
18f2861653bb class: EditField
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  2677
18f2861653bb class: EditField
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  2678
    passwordCharacter notNil ifTrue:[
6268
3d8b11c7df18 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6255
diff changeset
  2679
        self beepInEditor.
5041
18f2861653bb class: EditField
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  2680
        ^ self
18f2861653bb class: EditField
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  2681
    ].
5973
7e1d3c8aa4ad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5929
diff changeset
  2682
    ^ super setClipboardText:aString
7e1d3c8aa4ad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5929
diff changeset
  2683
7e1d3c8aa4ad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5929
diff changeset
  2684
    "Modified (format): / 21-11-2016 / 23:37:07 / cg"
5041
18f2861653bb class: EditField
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  2685
!
18f2861653bb class: EditField
Claus Gittinger <cg@exept.de>
parents: 4992
diff changeset
  2686
5042
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2687
setLastStringToReplace: sel
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2688
    "redefined to refuse to remember the password"
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2689
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2690
    passwordCharacter notNil ifTrue:[
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2691
        ^ self
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2692
    ].
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2693
    ^ super setLastStringToReplace: sel
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2694
!
c7dfd678de9b class: EditField
Claus Gittinger <cg@exept.de>
parents: 5041
diff changeset
  2695
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2696
validateNewSelection
6116
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2697
    "make certain that only one line is ever selected;
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2698
     also check that the selection is within the string"
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2699
1654
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2700
    selectionEndLine notNil ifTrue:[
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2701
        selectionEndLine > 1 ifTrue:[
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2702
            selectionEndLine := 2. selectionEndCol := 0
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2703
        ]
2569ec675d8a bug fix:
ca
parents: 1632
diff changeset
  2704
    ].
6116
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2705
    "/ new: 7.3.2017
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2706
    selectionStartCol notNil ifTrue:[
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2707
        selectionStartCol > (self contents size + 1) ifTrue:[
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2708
            selectionStartCol := self contents size + 1.
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2709
        ].    
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2710
        selectionEndCol notNil ifTrue:[
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2711
            selectionEndCol > (self contents size) ifTrue:[
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2712
                selectionEndCol := self contents size.
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2713
            ].    
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2714
        ].    
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2715
    ].
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2716
2e2e14a081f8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  2717
    "Modified (comment): / 07-03-2017 / 15:46:01 / cg"
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2718
! !
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2719
892
043b0ab4b786 allow acceptOnLostFocus.
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
  2720
!EditField class methodsFor:'documentation'!
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2721
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2722
version
5484
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2723
    ^ '$Header$'
3975
73674d16fc63 copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents: 3929
diff changeset
  2724
!
73674d16fc63 copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents: 3929
diff changeset
  2725
73674d16fc63 copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents: 3929
diff changeset
  2726
version_CVS
5484
73175b0903f9 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5240
diff changeset
  2727
    ^ '$Header$'
261
afcea54bd74e added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
  2728
! !
4507
5d052c1b7f02 class: EditField
Claus Gittinger <cg@exept.de>
parents: 4320
diff changeset
  2729