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