Skip to content

Commit 3410fe6

Browse files
authored
Merge pull request #4 from SetTrend/editNumber
`EditNumber` control added to documentation.
2 parents dfac25e + b9e02cd commit 3410fe6

File tree

3 files changed

+110
-20
lines changed

3 files changed

+110
-20
lines changed

docs/user-interface-tools/control-objects.rst

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,53 @@ To add to a window ``w``::
143143

144144
--------------------------------------------------------------------------------
145145

146+
.. _control-type-editnumber:
147+
148+
editnumber
149+
**********
150+
Class Name: ``EditNumber``
151+
152+
An editable text field the user can enter decimal numbers into. Fractions are allowed.
153+
Calls the :ref:`control-event-onchange` callback if the text is changed and the user types
154+
``ENTER`` or the control loses focus, or if its :ref:`controlobj-notify` method is called.
155+
Calls the :ref:`control-event-onchanging` callback when any change is made to the text.
156+
The ``textselection`` property contains currently selected text.
157+
158+
To add to a window ``w``::
159+
160+
w.add ("editnumber" [, bounds, text, minValue, maxValue, {creation_properties}]);
161+
162+
======================= ======================================================================================
163+
``bounds`` Optional. The control's position and size.
164+
``text`` Optional. The text displayed in the control.
165+
``minValue`` Optional. Minimum accepted value of number to be entered.
166+
``maxValue`` Optional. Maximum accepted value of number to be entered.
167+
``creation_properties`` Optional. An object that contains any of the following properties:
168+
169+
- ``name``: A unique name for the control.
170+
- ``readonly``: When false (the default), the control accepts text
171+
input. When true, the control does not accept input but only
172+
displays the contents of the ``text`` property.
173+
- ``noecho``: When false (the default), the control displays input
174+
text. When true, the control does not display input text
175+
(used for password input fields).
176+
- ``enterKeySignalsOnChange``: When false (the default), the
177+
control signals an :ref:`control-event-onchange` event when the editable text is
178+
changed and the control loses the keyboard focus (that is,
179+
the user tabs to another control, clicks outside the control, or
180+
types ``ENTER``). When true, the control only signals an
181+
``onChange`` event when the editable text is changed and the
182+
user types ``ENTER``; other changes to the keyboard focus do
183+
not signal the event.
184+
- ``borderless``: When true, the control is drawn with no
185+
border. Default is false.
186+
187+
======================= ======================================================================================
188+
189+
.. note:: The ``EditNumber`` control was added in Photoshop 20.0 (CC 2019).
190+
191+
--------------------------------------------------------------------------------
192+
146193
.. _control-type-edittext:
147194

148195
edittext
@@ -796,7 +843,8 @@ characters
796843
Type: ``Number``
797844

798845
Used by the :ref:`LayoutManager-object` to determine the default
799-
:ref:`controlobj-preferredSize` for a :ref:`StaticText` or :ref:`EditText` control. The control will be made wide enough to display the given number of `X` characters in
846+
:ref:`controlobj-preferredSize` for a :ref:`StaticText` or :ref:`EditText` control.
847+
The control will be made wide enough to display the given number of `X` characters in
800848
the font used by the control. Setting this property is the best way to
801849
reserve space in a control for a maximum number of characters to
802850
display.
@@ -1277,7 +1325,7 @@ new value into the ``text`` string at the current insertion point. The
12771325
``textselection`` value is reset to an empty string after it modifies the
12781326
``text`` value.
12791327

1280-
.. note:: Setting the ``textselection`` property before the edittext
1328+
.. note:: Setting the ``textselection`` property before the :ref:`EditText`
12811329
control's parent Window exists is an undefined operation.
12821330

12831331
--------------------------------------------------------------------------------
@@ -1852,23 +1900,26 @@ onChange
18521900
Called when the user finishes making a change in one of the following control
18531901
types:
18541902

1855-
================================ ================
1856-
:ref:`control-type-dropdownlist` :ref:`Scrollbar`
1857-
:ref:`EditText` :ref:`Slider`
1858-
:ref:`control-type-listbox` :ref:`control-type-treeview`
1859-
================================ ================
1860-
1861-
- For an :ref:`EditText` control, called only when the change is complete-that is, when
1862-
focus moves to another control, or the user types ``ENTER``. The exact behavior
1863-
depends on the creation parameter ``enterKeySignalsOnChange``; see the
1864-
:ref:`edittext <control-type-edittext>` description.
1903+
============================ ================
1904+
:ref:`EditNumber` :ref:`EditText`
1905+
:ref:`Scrollbar` :ref:`Slider`
1906+
:ref:`control-type-listbox` :ref:`control-type-dropdownlist`
1907+
:ref:`control-type-treeview`
1908+
============================ ================
1909+
1910+
- For :ref:`EditNumber` and :ref:`EditText` controls, called only when the change is
1911+
complete-that is, when focus moves to another control, or the user types ``ENTER``.
1912+
The exact behavior depends on the creation parameter ``enterKeySignalsOnChange``; see
1913+
the :ref:`edittext <control-type-edittext>` description.
18651914
- For a :ref:`Slider` or :ref:`Scrollbar`, called when the user has finished
18661915
dragging the position marker or has clicked the control.
1867-
- For a :ref:`control-type-listbox`, :ref:`control-type-dropdownlist` or :ref:`control-type-treeview` control, called
1868-
whenever the selection property changes. This can happen when a script sets the
1916+
- For a :ref:`control-type-listbox`, :ref:`control-type-dropdownlist` or :ref:`control-type-treeview`
1917+
control, called whenever the selection property changes. This can happen when a script sets the
18691918
property directly or removes a selected item from the list, or when the user
18701919
changes the selection.
18711920

1921+
.. note:: The ``EditNumber`` control was added in Photoshop 20.0 (CC 2019).
1922+
18721923
--------------------------------------------------------------------------------
18731924

18741925
.. _control-event-onchanging:
@@ -1877,13 +1928,15 @@ onChanging
18771928
**********
18781929
Called for each incremental change in one of the following control types:
18791930

1880-
=============== ================ =============
1881-
:ref:`EditText` :ref:`Scrollbar` :ref:`Slider`
1882-
=============== ================ =============
1931+
================= =============== ================ =============
1932+
:ref:`EditNumber` :ref:`EditText` :ref:`Scrollbar` :ref:`Slider`
1933+
================= =============== ================ =============
18831934

1884-
- For an :ref:`EditText` control, called for each keypress while the control has focus.
1935+
- For :ref:`EditNumber` and :ref:`EditText` controls, called for each keypress while the control has focus.
18851936
- For a :ref:`Slider` or :ref:`Scrollbar`, called for any motion of the position marker.
18861937

1938+
.. note:: The ``EditNumber`` control was added in Photoshop 20.0 (CC 2019).
1939+
18871940
--------------------------------------------------------------------------------
18881941

18891942
.. _control-event-oncollapse:

docs/user-interface-tools/defining-behavior-with-event-callbacks-and-listeners.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ to different actions, or events:
1515
``onShow`` and ``onClose``.
1616
- Button, RadioButton, and Checkbox controls generate events when the user clicks within the control
1717
bounds. To handle the event, define a callback function for :ref:`control-event-onclick`.
18-
- EditText, Scrollbar, and Slider controls generate events when the content or value changes-that is,
19-
when the user types into an edit field, or moves the scroll or slider indicator. To handle these events,
18+
- EditNumber, EditText, Scrollbar, and Slider controls generate events when the content or value changes-that
19+
is, when the user types into an edit field, or moves the scroll or slider indicator. To handle these events,
2020
define callback functions for :ref:`control-event-onchange` and :ref:`control-event-onchanging`.
2121
- ListBox, DropDownList, and TreeView controls generate events whenever the selection in the list
2222
changes. To handle the event, define a callback function for :ref:`control-event-onchange`.
@@ -32,6 +32,8 @@ to different actions, or events:
3232
for most types of controls. To handle the key sequence, define a callback function for
3333
:ref:`control-event-onshortcutkey` in that control.
3434

35+
.. note:: The ``EditNumber`` control was added in Photoshop 20.0 (CC 2019).
36+
3537
--------------------------------------------------------------------------------
3638

3739
.. _defining-event-handler-callback-functions:
@@ -95,6 +97,7 @@ The following controls generate the ``onClick`` event:
9597
The following controls generate the ``onChange`` event:
9698

9799
- ``DropDownList``
100+
- ``EditNumber``
98101
- ``EditText``
99102
- ``ListBox``
100103
- ``Scrollbar``
@@ -103,6 +106,7 @@ The following controls generate the ``onChange`` event:
103106

104107
The following controls generate the ``onChanging`` event:
105108

109+
- ``EditNumber``
106110
- ``EditText``
107111
- ``Scrollbar``
108112
- ``Slider``
@@ -117,6 +121,8 @@ clicked. For example, if the value of a checkbox ``hasBtnsCb`` is true, this cod
117121
dlg.hasBtnsCb.notify(); // dlg.hasBtnsCb.value is now false
118122
}
119123

124+
.. note:: The ``EditNumber`` control was added in Photoshop 20.0 (CC 2019).
125+
120126
--------------------------------------------------------------------------------
121127

122128
.. _registering-event-listeners-for-windows-or-controls:

docs/user-interface-tools/types-of-controls.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,37 @@ or replace::
142142
indicates a field in which a long text string can be entered. The text wraps to appear
143143
as multiple lines.
144144

145+
.. _editnumber:
146+
147+
EditNumber
148+
**********
149+
Allows users to enter a decimal number, which is returned to the script when the dialog is
150+
dismissed. The value entered is validated for being a localized number format and checked
151+
against a lower and upper boundary when the control loses focus. Text in EditNumber elements
152+
can be selected, copied, and pasted.
153+
154+
.. note:: The ``EditNumber`` control was added in Photoshop 20.0 (CC 2019).
155+
156+
- Set the ``text`` property to assign the initial displayed number in the element, and read
157+
it to obtain the current number value, as entered or modified by the user.
158+
159+
- Set the ``textselection`` property to replace the current selection with new text,
160+
or to insert text at the cursor (insertion point). Read this property to obtain the
161+
current selection, if any.
162+
163+
This example adds some EditNumber elements, with initial values that a user can accept
164+
or replace::
165+
166+
var dlg = new Window( "dialog", "Date Box" );
167+
dlg.msgPnl = dlg.add( "panel", undefined, "Enter Date" );
168+
dlg.msgPnl.titleSt = dlg.msgPnl.add( "statictext", undefined, "Month:" );
169+
dlg.msgPnl.titleEt = dlg.msgPnl.add( "editnumber", undefined, 1, 1, 12 );
170+
dlg.msgPnl.msgSt = dlg.msgPnl.add( "statictext", undefined, "Year:" );
171+
dlg.msgPnl.msgEt = dlg.msgPnl.add( "editnumber", undefined, 2025, 2000, 2100 );
172+
dlg.show();
173+
174+
.. note:: Decimal numbers like ``2.5`` are accepted for minimum and maximum values.
175+
145176
.. _checkbox:
146177

147178
Checkbox

0 commit comments

Comments
 (0)