View on GitHub

UI-with-Classes

Collection of 4D classes dedicated to user interface management, designed to structure the UI and make code more readable, maintainable, and reusable.

group

Widget groups are available in the form editor but are not recognized at runtime.

Hierarchy

A classic way to handle this is to create name patterns to handle a group of widgets at once. This is sometimes a problem when you want to change the organization of the form.

The purpose of thegroup class is to allow the manipulation of a collection of widgets without having to worry about the name of the widget in the form

The group class is available via the form class through the Group interface.

Example

This.form:=cs.form.new(This)
...
This.bottomButtons:=This.form.Group()
This.ok:=This.form.Button("Button").addToGroup(This.bottomButtons)
This.cancel:=This.form.Button("Button1").addToGroup(This.bottomButtons)

...
This.bottomButtons.distributeRigthToLeft()

This class is, more generally, available from the cs class store, or cs.ui class store if you use the UI component.

Example

$group:=cs.ui.group.new("Button,Button1")
$group.distributeRigthToLeft().disable()

ℹ️ Conventions

  1. To simplify the distinction between form objects and object type, this documentation uses the term “widget” for all form objects, whether static (a line, a rectangle…) or not (a button, a subform…).
  2. All functions that return This return the current group object and can include one call after another.

cs.group.new()

cs.group.new ( ) : cs.group
cs.group.new ( members : Collection ) : cs.group
cs.group.new ( member : widget | cs.group {; … {; memberN widget | cs.group}}) : cs.group
cs.group.new ( member : Text {; … {; memberN Text {; type :Text} ) : cs.group

The constructor accepts an optionalmembers parameter of type Collection, Object, or text.

Parameter Type   Description
member Variant  

Description

cs.group.new() creates & returns a new instance of the class.

⚠️ Type analysis is based on its name, checking whether the corresponding class exists in the class store. In this case, it is important to avoid confusion between the last parameter and a component class (for example, if the name is “group” or “button”). Note that the search is case-sensitive.

Properties & Functions

Properties

Properties Description Type default Writable
.data User data: anything you wish to associate with the group and retrieve at a later date. any Null
.members The collection of wigdets that belong to the group Collection empty x
.type The class type Integer Object type group x

Functions

Functions  
.add (members ) →This Adds one or more widgets to the group. (same syntax as the constructor)
.alignLeft (reference :Object) →This
.alignLeft (left :Integer) →This
.alignLeft (reference :Text) →This
Performs a left alignment of the elements relative to the left position of the reference or the pixel value passed
.alignRight (reference :Object) →This
.alignLeft (right :Integer) →This
.alignLeft (reference :Text) →This
Performs a right alignment of the elements relative to the left position of the reference or the pixel value passed
.belongsTo (name :Text) →:Boolean
.belongsTo (widget :Object) →:Boolean
Returns True if the passed object or object name is part of the group
.center (horizontally :Boolean) Center all members on the first
.centerVertically (reference :Text) Performs a centered alignment of the elements according to their best size
.disable () →This To disable all elements
.enable ({enabled :Boolean}) →This To enable all elements (without parameter) or not (enabled = False)
.moveAndResizeHorizontally (offset :Integer ; resize :Integer) Moves & resize all members horizontally
.distributeAroundCenter ({params :Object}) →This Performs a horizontal distribution, around the center of the group, of the elements according to their best size*
.distributeHorizontally ({params :Object}) →This Performs an horizontal distribution of the element saccording to their best size*
.distributeLeftToRight ({params :Object}) →This Performs a horizontal distribution, from left to right, of the elements according to their best size*
.distributeRigthToLeft ({params :Object}) →This Performs a horizontal distribution, from right to left, of the elements according to their best size*
.distributeVertically ({params :Object}) →This Performs a vertical distribution of the elements*
.enclosingRect ({padding :Integer}) →Object Returns the coordinates of the enclosing rectangle, respecting the padding parameter if passed
.hide () →This Makes all elements invisible
.horizontallyCentered ({params :Object {; ref :Text}) →This Performs a horizontal alignment of the elements.
The optional widget name parameter allows specifying the reference. If omitted, the distribution is relative to the form
.move (hOffset :Integer ; vOffset :Integer) Move all members horizontally & vertically
.moveDown (offset :Integer) Moves down all members
.moveUp (offset :Integer) Move all members upwards
.moveHorizontally (offset :Integer) Moves all members horizontally
.moveLeft (offset :Integer) Moves left all members
.moveRight (offset :Integer) Move right members upwards
.moveVertically (offset :Integer) Moves all members vertically
.setFontStyle (style :Integer) →This Sets the font style of all elements. Use the 4D Font style constantes
.show ({visible :Boolean}) →This Makes all elements visible if visible is True or omitted
.switch ({updateEntryOrder :Boolean }) →This Reverses the horizontal order of the members. Useful, for example, for reversing the OK and Cancel buttons depending on the platform
.verticallyCentered ({params :Object {; ref:Text}) →This Performs a centered alignment of the elements.
The optional widget name parameter allows specifying the reference. If omitted, the distribution is relative to the form

* The optional object type parameter allow to specify:

Coordinate object

{
  left: integer, 
  top: integer,
  right: integer,
  bottom: integer
}

Integration Notes

Recent integration adds utility APIs: