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.

button

The button class provides an interface to manage properties and actions of button widget.

Hierarchy


ℹ️ Important

  1. This class inherit from the widget class
  2. 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…).
  3. All functions that return This may include one call after another.

The button class is available via the form class through the Button interface.

Example

This.form:=cs.form.new(This)
...
This.myButton:=This.form.Button("button1")
...
This.myButton.disable()

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

Example

Form.myButton:=cs.ui.button.new("button")
Form.myButton.enable()

cs.button.new()

cs.button.new ( name : Text) : cs.button
cs.button.new ( name : Text ; parent : Object) : cs.button
cs.button.new ( ) : cs.button

Parameter Type   Description
name Text Widget name
parent cs.form form object containing the widget
result cs.button New cs.button

Description

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

⚠️ Omitting the widget name can only be used if the constructor is called from the object method.

Properties & Functions

Inherited properties and functions are described in the parent classes:

Properties

Properties Description Type Writable
.backgroundPicture Associated background picture proxy Text
.horizontalMargin Number of pixels delimiting the inside left and right margins of the button Integer
.linkedPopupMenu With linked pop-up menu (False = no associated menu) Boolean
.numStates Number of states present in picture used as icon for the button Integer
.picture Associated picture proxy Text
.separatePopupMenu With separate pop-up menu (False = no associated menu) Boolean
.style Button style* Integer
.styleName The current button style name* Text x

Functions

Functions  
.highlightShortcut ( ) →This Underlines the first uppercase letter of the title corresponding to the keyboard shortcut. If not found, the first lowercase letter, if any
📌 Automatically called when you use the .setShortcut() function.
.is3DButton ( ) →This Returns True if the current button is a 3D button
.setBackgroundPicture (proxy : Text) →This Sets the background picture (deletes it if the proxy parameter is omitted)
.setLinkedPopupMenu () →This Sets the button to display and manage a linked pop-up menu
.setNoPopupMenu () →This Removes associated pop-up menu
.setNumStates (state : Integer) →This Sets number of states present in picture (restore to 4 if no parameter)
.setPicture ( proxy : Text ) →This Sets the associated picture (deletes it if the proxy parameter is omitted)
.setSeparatePopupMenu () →This Sets the button to display and manage a separate pop-up menu*
.setStyle (style : Integer) →This Defines button style**

* Adding or deleting a linked or associated menu automatically activates/deactivates the object’s form event On Alternative Click of the widget.
** The following style values are possible:

style = 0: None (default)
style = 1: Background offset
style = 2: Push button
style = 3: Toolbar button
style = 4: Custom
style = 5: Circle
style = 6: Small system square
style = 7: Office XP
style = 8: Bevel
style = 9: Rounded bevel
style = 10: Collapse/Expand
style = 11: Help
style = 12: OS X Textured
style = 13: OS X Gradient

Integration Notes

Recent integration adds adaptive sizing behavior based on widget.newUI: