Skip to content

Commit

Permalink
inputDelegate doc
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Oct 3, 2023
1 parent eb738e7 commit c9495e8
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 29 deletions.
85 changes: 57 additions & 28 deletions Documentation/Classes/inputDelegate.md
Original file line number Diff line number Diff line change
@@ -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** | <font color="green">X</font>
|**.filter** | The entry filter | `Integer`\* \| `Text`\* | - | <font color="green">X</font>
|**.placeholder** | The placeholder text | `Text`\*\* | - | <font color="green">X</font>
|**.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:<br/>- All text if no parameters are passed<br/>- From `start` to the end of the text if the `end` parameter is omitted<br/>- 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`<br/>.**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`<br/>.**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:<br/>* All text if no parameters are passed<br/>* From `start` to the end of the text if the `end` parameter is omitted<br/>* 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.


#### <a name="selectionObject">Selection object</a>

```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

\***
31 changes: 30 additions & 1 deletion Project/Sources/Classes/inputDelegate.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Expand Down

0 comments on commit c9495e8

Please sign in to comment.