Event Handling Architecture example

If you’re looking for a way to add some interactivity to your mobile applications, the Button OnClick through Actions demo is a great place to start. This cross-platform application shows you how to define an OnClick event on a button and have it change another interface element. Built in Delphi using a single code base and single UI, the Button OnClick demo is perfect for Android, iOS, macOS, Windows, and Linux. So why wait? Give it a try today and see how easy it is to add some excitement to your app development!

Download the full cross-platform event handling OnClick event source code on Github.

This demo is part of over 100 cross-platform demos with everything from camera demos to emoji demos and painting demos.

What is event-handling architecture in software development?

Event-handling architecture is a design pattern that allows software developers to write event-driven code. In event-driven programming, a piece of code is executed in response to an event. Events can be generated by the user, by the system, or by other software components. Event-handling architecture makes it possible to write code that is responsive to events without having to write complex event handling logic. This can make code more modular and reusable, and can make it easier to debug and maintain. Event-handling architecture is a powerful tool for developing event-driven code, and can be used in a variety of software development contexts.

Screenshot

What does the source code look like for the event handling?

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
  FMX.Effects, FMX.Controls.Presentation, System.Actions, FMX.ActnList;

type
  TForm1 = class(TForm)
    MaterialOxfordBlueSB: TStyleBook;
    ToolBar1: TToolBar;
    ShadowEffect4: TShadowEffect;
    Label1: TLabel;
    Button1: TButton;
    Label2: TLabel;
    ActionList1: TActionList;
    ButtonOnClickAction: TAction;
    procedure ButtonOnClickActionExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.ButtonOnClickActionExecute(Sender: TObject);
begin
  Label2.Text := DateTimeToStr(Now);
end;

end.

Ready to learn how to program cross-platform apps like this?

Sign up for the Coding Boot Camp 2022 to learn to program. Topics include: Games, JavaScript, Web, Python, SQL, Databases, iOS, MacOS, Android, Mobile, Linux, Windows, Desktop, Server, and Arduino.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition