CustomAction¶
Qualified name: delphifmx.CustomAction
- class CustomAction¶
Bases:
ContainedAction
TCustomAction is a base class for FireMonkey actions intended to be used with menu items and controls. TCustomAction introduces support for the properties, events, and methods of menu items and controls that are clients of actions. Most properties and events introduced in TCustomAction are public; therefore, use TCustomAction as a base class when deriving your own actions that publish specific subset of properties of associated controls. Actions centralize responses to user commands (user actions). An action is associated with the user interface elements (components) in an application that uses this action. Actions provide an easy way to synchronize values of properties of an action and of associated components (clients), for example, the enabled state and caption of an action and of an associated speed button and a menu item, and handle the response when the user clicks these components. Each component, which is called the client, has its properties dynamically updated by the associated action and forwards user commands to the action for a response. The Text property can be used to set an accelerator key to the action. Notice that & and _ are seen and can be used only for Windows. At design time, you can work in the Action List editor with actions contained in an action list. The action list is a container for actions, organized into categories (File, Edit, and others). Public properties and events of a component and control that are supported in TCustomAction, either directly or through an ancestor, are the following:
Properties: Caption, Checked, Enabled, HelpType, HelpContext, HelpKeyword, Hint, ImageIndex, ShortCut, Visible. Events: OnHint, OnUpdate, OnExecute. TCustomAction is the base class for TAction and TCustomViewAction. TCustomAction acts as the base class for several predefined action classes. For predefined actions that augment the behavior of TCustomAction, see the action classes in the FMX.StdActns unit.
Code Examples FMX.ActionsDemo Sample FMX.KeyboardToolbar Sample FMX.ScrollableForm Sample
Methods
Generates an OnExecute event.
Checks whether the specified keyboard key corresponds to one of the action's shortcuts.
Provides an opportunity to execute centralized code when an application is idle.
Attributes
Indicates the client component that caused this action to execute.
Holds the action list to which the action belongs.
AutoCheck
Controls whether the Checked property toggles when the action executes.
Represents the caption of the action.
Category
Group or category where the action belongs.
Checked
Indicates whether client controls and menu items appear checked.
ClassName
Returns the TObject.ClassName
ComObject
Specifies the interface reference implemented by the component.
ComponentCount
Returns the owned component count
ComponentIndex
Indicates the position of the component in its owner's Components property array.
ComponentState
Describes the current state of the component, indicating when a component needs to avoid certain actions.
ComponentStyle
Governs the behavior of the component.
Components
Returns an iterator over the owned components
DesignInfo
Contains information used by the Form designer.
DisableIfNoHandler
Indicates whether the action's clients should be disabled if no OnExecute event handler is found.
Enabled
Specifies the enabled state for the action.
GroupIndex
Indicates a group of actions in one action list.
HelpContext
Keeps the integer context ID that identifies the Help topic for the action.
HelpKeyword
Contains the keyword string that identifies the Help topic for the action.
HelpType
Keeps whether to use the HelpContext or HelpKeyword property to identify the Help topic.
Defines whether the UnSupported action can be visible and accessible.
Hint
Stores the Help hint text.
ImageIndex
Stores an index in a list of images.
Index
Specifies the index of the action in its action list.
Name
Specifies the name of the component as referenced in code.
Observers
Indicates the TObservers object added to the TComponent.
Owner
Returns the Component Owner
SecondaryShortCuts
Stores shortcuts (in addition to ShortCut) for triggering the action.
ShortCut
Shortcut that triggers the action.
Specifies that the action is fired by pressing a keyboard key, not by clicking with the mouse.
StatusAction
Stores the status for an input field in an action.
Defines whether the action can work on the current platform and CPU architecture.
Tag
Stores a NativeInt integral value as a part of a component.
Defines the component for which the action is executed.
Represents the caption of the action.
Defines the set of unsupported CPU architectures.
Defines the set of unsupported OS platforms.
VCLComObject
Represents information used internally by components that support COM.
Visible
Stores whether the action representation is visible.
- ActionComponent¶
Indicates the client component that caused this action to execute.
- ActionList¶
Holds the action list to which the action belongs. FMX.ActnList.TCustomAction.ActionList inherits from System.Actions.TContainedAction.ActionList. All content below this line refers to System.Actions.TContainedAction.ActionList. Holds the action list to which the action belongs.
- Type:
- Caption¶
Represents the caption of the action. Caption holds the string that is used as the caption of the action, when it is set. The value of Caption can be propagated to all client controls and client menu items linked to the action.
- Type:
str
- Execute()¶
Generates an OnExecute event.
- HideIfUnsupportedInterface¶
Defines whether the UnSupported action can be visible and accessible. If HideIfUnsupportedInterface is True, then the IsSupportedInterface function is used for retrieving the value of the Supported property. In this case, if IsSupportedInterface returns False, then this action is always inaccessible and invisible. If HideIfUnsupportedInterface is False, then this action can be visible or invisible depending on other properties. In this case, descendant classes or application objects should call IsSupportedInterface to retrieve the visibility and accessibility of the action.
- Type:
bool
- IsDialogKey(Key: int, Shift: ShiftState) bool ¶
Checks whether the specified keyboard key corresponds to one of the action’s shortcuts. IsDialogKey returns True if the keyboard key specified by the combination of Key and Shift corresponds to one of the action’s shortcuts. Here:
Key is a keyboard scan code. You can find constants for keyboard scan codes in the Constants section of the System.UITypes unit. These are vkXXXX constants (vkEscape, vkReturn, vkF1, and others). Shift specifies the combination of the ALT, CTRL, SHIFT, and CMD (only Mac) keys. The action’s shortcuts are listed in the ShortCut and SecondaryShortCuts properties.
- ShortCutPressed¶
Specifies that the action is fired by pressing a keyboard key, not by clicking with the mouse. ShortCutPressed is a read-only property. When ShortCutPressed is True, it specifies that the action is fired by pressing a keyboard key, and not by clicking a control with the mouse.
- Type:
bool
- Supported¶
Defines whether the action can work on the current platform and CPU architecture. Supported is a read-only property. Supported defines whether the action can work on the current platform and CPU architecture. The value of this property is defined by the UnsupportedArchitectures and UnsupportedPlatforms properties and also by the IsSupportedInterface function. If Supported is False, then this action is always inaccessible and invisible.
- Type:
bool
- Target¶
Defines the component for which the action is executed. Target is a read-only property. Target defines the component for which the action is executed. It can be nil. In the case where several controls can be called with one shortcut, Target corresponds to the first matched control.
- Type:
- Text¶
Represents the caption of the action. Text holds the string that is used in the same way as the Caption of the action, when it is set. The value of Text is propagated to the action’s clients. Text is the same as Caption. You can use both Text and Caption, but descendant classes should only use the published property Text, so that the Object Inspector displays only the Text property, as in most FireMonkey components. In the Text property you can define an accelerator key. On Windows platforms, an accelerator key is shown as an underlined letter. To specify an accelerator key, precede an <accelerator_letter> with an ampersand & character. The letter after the ampersand appears underlined. For example, to set the S character as an accelerator key for a Save action, type &Save. On Windows platforms, accelerator keys enable the user to activate actions pressing Alt+<accelerator_letter> key combination. To show a single ampersand & character in a Text property specify doubled ampersand && characters. Notice that & and _ are seen and can be used only under Windows.
- Type:
str
- UnsupportedArchitectures¶
Defines the set of unsupported CPU architectures. The TArchitecture type defines the arIntelX86 and arIntelX64 constants that identify the processor architectures Intel x86 and Intel x64. Use UnsupportedArchitectures to identify sets of unsupported processor architectures.
- Type:
Architectures
- UnsupportedPlatforms¶
Defines the set of unsupported OS platforms. The TPlatform type defines the pfWindows, pfMacOS, pfiOS, pfAndroid, and pfLinux constants that identify the Windows, Mac OS, Android, and other platforms. Use UnsupportedPlatforms to identify sets of unsupported OS platforms.
- Type:
Platforms
- Update()¶
Provides an opportunity to execute centralized code when an application is idle.