CustomAction¶
Qualified name: delphifmx.CustomAction
- class CustomAction¶
Bases:
ContainedActionTCustomAction 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
TBasicAction.Execute() Generates an OnExecute event.
TCustomAction.IsDialogKey(Key: int, Shift: ShiftState) -> bool Checks whether the specified keyboard key corresponds to one of the action's shortcuts.
TBasicAction.Update() 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.
AutoCheckControls whether the Checked property toggles when the action executes.
Represents the caption of the action.
CategoryGroup or category where the action belongs.
CheckedIndicates whether client controls and menu items appear checked.
ClassNameReturns the TObject.ClassName
ComObjectSpecifies the interface reference implemented by the component.
ComponentCountReturns the owned component count
ComponentIndexIndicates the position of the component in its owner's Components property array.
ComponentStateDescribes the current state of the component, indicating when a component needs to avoid certain actions.
ComponentStyleGoverns the behavior of the component.
ComponentsReturns an iterator over the owned components
DesignInfoContains information used by the Form designer.
DisableIfNoHandlerIndicates whether the action's clients should be disabled if no OnExecute event handler is found.
EnabledSpecifies the enabled state for the action.
GroupIndexIndicates a group of actions in one action list.
HelpContextKeeps the integer context ID that identifies the Help topic for the action.
HelpKeywordContains the keyword string that identifies the Help topic for the action.
HelpTypeKeeps whether to use the HelpContext or HelpKeyword property to identify the Help topic.
Defines whether the UnSupported action can be visible and accessible.
HintStores the Help hint text.
ImageIndexStores an index in a list of images.
IndexSpecifies the index of the action in its action list.
NameSpecifies the name of the component as referenced in code.
ObserversIndicates the TObservers object added to the TComponent.
OwnerReturns the Component Owner
SecondaryShortCutsStores shortcuts (in addition to ShortCut) for triggering the action.
ShortCutShortcut that triggers the action.
Specifies that the action is fired by pressing a keyboard key, not by clicking with the mouse.
StatusActionStores the status for an input field in an action.
Defines whether the action can work on the current platform and CPU architecture.
TagStores 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.
VCLComObjectRepresents information used internally by components that support COM.
VisibleStores 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.