Delphi has introduced a great number of features over the years. Every time a new version of RAD Studio arrives, a new set of features and functionalities will also be introduced. However, with an overwhelming number of features available, some components are either forgotten, misused or failed to showcase their full potential. The Actions, for instance, have been in Delphi for a long time. These non-visual components were introduced in Delphi 4 and have become one of the core features of the language and are applied both to VCL (Windows application development) and FMX (cross-platform applications). Unfortunately, despite being in Delphi for a long time, Actions and Action Lists are some of the components in Delphi that are not being used as often as they should.
What are actions and why we should use them?
Generally, an action is a non-visual component that represents a user-generated command. It allows you to set up all the UI properties related to that command in one central place, along with the code required to execute the command and also code that can control if the command is available to the user or not. Actions are managed either through Action List or Action Manager which are both non-visual components in Delphi.
Ray Konopka also highlights the two base components of Actions that we might need to leverage. These are the TActionlist
that literally manages a set of TAction
components and provides design-time access to actions. Another base component is the TAction itself which generally implements a command on a target and is invoked by the client controls. It is also interesting to note that those things that we commonly interact with such as the buttons and menus have Action properties so you can connect your Client control with the Action.
Developers should use Action more often as they have many powerful benefits and can make your code easier to maintain. They allow application code to be modularized and defined independently of the controls that will invoke the code. Actions also centralize updates and things like visibility and enablement, thereby updating the action’s clients.
In this video, Konopka will demonstrate how exactly the Actions component works in Delphi. He will also provide a set of performance tips that you might consider applying to your project in the future. At the end of the video is a live Q & A with Ray and Embarcadero Delphi MVP Ian Barker where they answer live viewer’s questions.
To know more about Actions and to learn about their full potential, feel free to watch this video from the recently concluded DelphiCon 2023 below.
Conception. Code. Compiler. Déployer.
Commencer l'essai gratuitMettre à jour aujourd'hui
Édition communautaire Delphi gratuiteÉdition communautaire gratuite de C ++ Builder