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.
Table of Contents
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?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
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; <strong> ActionList1: TActionList; ButtonOnClickAction: TAction; procedure ButtonOnClickActionExecute(Sender: TObject);</strong> private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} <strong>procedure TForm1.ButtonOnClickActionExecute(Sender: TObject); begin Label2.Text := DateTimeToStr(Now); end;</strong> 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.
Design. Code. Compile. Deploy.
Start Free TrialUpgrade Today
Free Delphi Community EditionFree C++Builder Community Edition