From c9495e8c0cf0bcb7f3d6d97b1310be54ca9ffe47 Mon Sep 17 00:00:00 2001 From: Vincent de Lachaux Date: Tue, 3 Oct 2023 19:33:12 +0200 Subject: [PATCH] inputDelegate doc --- Documentation/Classes/inputDelegate.md | 85 +++++++++++++++-------- Project/Sources/Classes/inputDelegate.4dm | 31 ++++++++- 2 files changed, 87 insertions(+), 29 deletions(-) diff --git a/Documentation/Classes/inputDelegate.md b/Documentation/Classes/inputDelegate.md index 9bda5b5..ef762fc 100644 --- a/Documentation/Classes/inputDelegate.md +++ b/Documentation/Classes/inputDelegate.md @@ -1,42 +1,71 @@ # input -The `input` class is intended to handle input widget. +The `inputDelegate` class is intended to handle input widget. -> #### 📌 This class inherit from the [`widget`](widget.md) class +📌 This class inherit from the [`widgetDelegate`](widgetDelegate.md) class -## Properties - -|Properties|Description| -|----------|-----------| -|**.name** | [*inherited*](formObject.md) | -|**.type** | [*inherited*](formObject.md) | -|**.coordinates** | [*inherited*](formObject.md) | -|**.dimensions** | [*inherited*](formObject.md) | -|**.windowCoordinates** | [*inherited*](formObject.md) | -|**.action** | [*inherited*](widget.md) | -|**.assignable** | [*inherited*](widget.md) | -|**.pointer** | [*inherited*](widget.md) | -|**.value** | [*inherited*](widget.md) | +#### This class is available via the [`formDelegate`](formDelegate.md#objects) class as `input` interface. -## 🔸 cs.input.new() +```4D +This.form.input.new("formObjectName") +``` -The class constructor `cs.input.new({formObjectName})` creates a new class instance. +#### This class can also be instantiated on its own. +```4D +cs. inputDelegate.new({"formObjectName"}) +``` If the `formObjectName` parameter is ommited, the constructor use the result of **[OBJECT Get name](https://doc.4d.com/4Dv18R6/4D/18-R6/OBJECT-Get-name.301-5198296.en.html)** ( _Object current_ ) > 📌 Omitting the object name can only be used if the constructor is called from the object method. -## Summary +## Properties + +All the properties of the extended class, plus: -> 📌 All functions that return `cs.input` may include one call after another. +|Properties|Description|Type|default|Writable| +|:----------|:-----------|:-----------|:-----------|:-----------:| +|**.asPassword** | Input field as password entry | `Boolean` | **False** | X +|**.filter** | The entry filter | `Integer`\* \| `Text`\* | - | X +|**.placeholder** | The placeholder text | `Text`\*\* | - | X +|**.modified** | Modified state of the field after calling the `backup()` function| `Boolean` | **False** + +## Functions + +All the functions of the extended class, plus: | Function | Action | -| -------- | ------ | -|.**highlight** ({start`:Integer`{; end`:Integer`}}) →`:cs.input` | Highlights:
- All text if no parameters are passed
- From `start` to the end of the text if the `end` parameter is omitted
- From `start` to `end` if `start` & `end` are passed | -|.**highlightLastToEnd** () →`:cs.input` | Highlights the text from the last character entered to the end | -|.**highlighted** () →`:Object` | Returns the start & end positions of currently selected text as object: `{ start, end }` | -|.**highlightingStart** () →`:Integer` | Returns the start position of currently selected text | -|.**highlightingEnd** () →`:Integer` | Returns the end position of currently selected text | -|.**highlightingEnd** () →`:Integer` | Returns the end position of currently selected text | -|.**setFilter** ( filter`:Integer`) →`:cs.input`
.**setFilter** ( filter`:Text`) →`:cs.input` | Sets the entry filter for the widget. Use [4D constants](https://doc.4d.com/4Dv19/4D/19/Field-and-Variable-Types.302-5393351.en.html) (ie. _Is date_ or _Is integer_) for default predefined formats or pass the filter definition as text. | -|.**getFilter** () →`:Text` | Returns the current filter associated with the widget if any. | +| -------- | ------ | +|.**getFilter** () → `Text` | Returns the current filter associated with the widget if any. +|.**setFilter** ( filter: `Integer`\*) → `inputDelegate`
.**setFilter** ( filter: `Text`\*) → `inputDelegate` | Sets the entry filter for the widget. +|.**setPlaceholder** ( `Text`\*\*) → `cs.inputDelegate` | Sets the placeholder text +|.**highlight** ({start: `Integer` {; end: `Integer`}}) → `cs.inputDelegate` | Highlights:
* All text if no parameters are passed
* From `start` to the end of the text if the `end` parameter is omitted
* From `start` to `end` if `start` & `end` are passed +|.**highlightLastToEnd** () → `cs.inputDelegate` | Highlights the text from the last character entered to the end +|.**highlighted** () → `Object` | Returns the selection status of the field as a [selection object](#selectionObject). +|.**highlightingStart** () → `Integer` | Returns the start position of currently selected text +|.**highlightingEnd** () → `Integer` | Returns the end position of currently selected text +|**.backup ()** | Stores the current input value. + + +#### Selection object + +```json +{ + start: (Integer), + end: (Integer), + length: (Integer), + withSeletion: (Boolean), + noSelection: (Boolean), + selection: (Text) +} +``` + +> 📌 All functions that return `cs.inputDelegate` may include one call after another. + +---- + +\* Use [4D constants](https://doc.4d.com/4Dv19/4D/19/Field-and-Variable-Types.302-5393351.en.html) (ie. _Is date_ or _Is integer_) for default predefined formats or pass the filter definition as text. Some predefined filters are available: `"url"`, `"email"`, `"noCr"`, `"noSpaceNorCr"` + +\** Accepts an xliff resname, if so, uses the localized string + +\*** diff --git a/Project/Sources/Classes/inputDelegate.4dm b/Project/Sources/Classes/inputDelegate.4dm index e0b8f58..b3e74a7 100644 --- a/Project/Sources/Classes/inputDelegate.4dm +++ b/Project/Sources/Classes/inputDelegate.4dm @@ -77,8 +77,37 @@ Function set filter($filter) Else - OBJECT SET FILTER:C235(*; This:C1470.name; String:C10($filter)) + $filter:=String:C10($filter) + Case of + + //______________________________________________________ + : ($filter="email") + + OBJECT SET FILTER:C235(*; This:C1470.name; "&\"a-z;0-9;@;.;-;_\"") + + //______________________________________________________ + : ($filter="url") + + OBJECT SET FILTER:C235(*; This:C1470.name; "&\"a-z;0-9;@;.;-;_;:;#;%;/;?;=\"") + + //______________________________________________________ + : ($filter="noSpaceNorCr") + + OBJECT SET FILTER:C235(*; This:C1470.name; "&\"!-ÿ\"") + + //______________________________________________________ + : ($filter="noCr") + + OBJECT SET FILTER:C235(*; This:C1470.name; "&\" -ÿ\"") + + //______________________________________________________ + Else + + OBJECT SET FILTER:C235(*; This:C1470.name; $filter) + + //______________________________________________________ + End case End if // <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==