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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| unit keypadframe;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
FMX.Controls.Presentation, FMX.Layouts, FMX.Memo.Types, FMX.ScrollBox,
FMX.Memo, FMX.Edit;
type
TMyKeyboard = class(TFrame)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Btnshift: TButton;
FlowLayout1: TFlowLayout;
procedure BtnshiftClick(Sender: TObject);
procedure keyclick(Sender: TObject);
private
{ Déclarations privées }
upkeys : boolean;
aMemo : TMemo;
aEdit : TEdit;
procedure drawkeys;
public
{ Déclarations publiques }
constructor Create(AOwner: TComponent) ; override;
end;
const C_Lower : TArray<Char>=[Char($00DF),Char($00E6),Char($0153),Char($2191)];
const C_Upper : TArray<Char>=[Char($1E9E),Char($00C6),Char($0152),Char($2191)];
implementation
{$R *.fmx}
procedure TMyKeyboard.BtnshiftClick(Sender: TObject);
begin
upKeys:=not UpKeys;
DrawKeys;
end;
constructor TMyKeyboard.Create(AOwner: TComponent);
begin
inherited;
upkeys:=False;
if Tpopup(AOwner).PlacementTarget is TEdit then AEdit:=TEdit(Tpopup(AOwner).PlacementTarget);
if Tpopup(AOwner).PlacementTarget is TMemo then AMemo:=TMemo(Tpopup(AOwner).PlacementTarget);
drawkeys;
end;
procedure TMyKeyboard.drawkeys;
var i : integer;
begin
for I := 0 to FlowLayout1.Controls.Count-1 do
if FlowLayout1.Controls[i] is TButton then
begin
if Upkeys then TButton(FlowLayout1.Controls[i]).Text:=Char(C_Upper[i])
else TButton(FlowLayout1.Controls[i]).Text:=Char(C_lower[i])
end;
end;
procedure TMyKeyboard.keyclick(Sender: TObject);
begin
If Assigned(AMemo) then AMemo.Text:=AMemo.text+TButton(Sender).Text;
if Assigned(AEdit) then AEdit.Text:=AEdit.text+TButton(Sender).Text;
end;
end. |
Partager