fix(android): the clear cross lives beside the field, not inside it
It was a TLabel, and in FMX a label does not take clicks - HitTest is False by default there. But fixing that alone would not have been enough: a child placed inside a TEdit does not reliably receive touches, the native control claims them across its whole surface. It now sits in a wrapper next to the field, as a transparent rectangle with the cross drawn inside it - one Right and one Client, so there is no stacking order to guess either. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+31
-15
@@ -103,7 +103,8 @@ type
|
||||
// --- ecran 2 : liste
|
||||
FLayList: TLayout;
|
||||
FSearch: TEdit;
|
||||
FSearchHint, FSearchClear: TLabel;
|
||||
FSearchHint: TLabel;
|
||||
FSearchClear: TRectangle;
|
||||
/// Choix du dossier : un bouton peint, et un panneau de selection montre
|
||||
/// a la demande. FFolders[0] est toujours « tous les dossiers ».
|
||||
FBtnFolder: TRectangle;
|
||||
@@ -383,8 +384,9 @@ end;
|
||||
|
||||
procedure TForm8.BuildList;
|
||||
var
|
||||
LBar, LTop: TLayout;
|
||||
LBar, LTop, LSearchWrap: TLayout;
|
||||
LBtnLock: TRectangle;
|
||||
LClearMark: TLabel;
|
||||
begin
|
||||
FLayList := TLayout.Create(Self);
|
||||
FLayList.Parent := Self;
|
||||
@@ -437,11 +439,37 @@ begin
|
||||
FBtnFolder.Width := 170;
|
||||
FBtnFolder.Margins.Left := 8;
|
||||
|
||||
// La croix vit A COTE du champ, pas dedans. Un enfant place dans un TEdit
|
||||
// ne recoit pas les touches de facon fiable : le controle natif les capte
|
||||
// sur toute sa surface. Un conteneur avec un Right et un Client leve en
|
||||
// plus toute question d'ordre.
|
||||
LSearchWrap := TLayout.Create(Self);
|
||||
LSearchWrap.Parent := LTop;
|
||||
LSearchWrap.Align := TAlignLayout.Client;
|
||||
|
||||
FSearchClear := TRectangle.Create(Self);
|
||||
FSearchClear.Parent := LSearchWrap;
|
||||
FSearchClear.Align := TAlignLayout.Right;
|
||||
FSearchClear.Width := 46;
|
||||
FSearchClear.Fill.Kind := TBrushKind.None; // invisible, mais cliquable
|
||||
FSearchClear.Stroke.Kind := TBrushKind.None;
|
||||
FSearchClear.Visible := False;
|
||||
FSearchClear.OnClick := OnSearchClear;
|
||||
|
||||
LClearMark := TLabel.Create(FSearchClear);
|
||||
LClearMark.Parent := FSearchClear;
|
||||
LClearMark.Align := TAlignLayout.Client;
|
||||
LClearMark.HitTest := False; // le clic va au rectangle
|
||||
LClearMark.Text := 'X';
|
||||
LClearMark.TextSettings.HorzAlign := TTextAlign.Center;
|
||||
LClearMark.TextSettings.VertAlign := TTextAlign.Center;
|
||||
Tint(LClearMark, 17, True);
|
||||
|
||||
// Le champ reste natif - il faut un clavier - et son fond vient desormais du
|
||||
// style, recolore a la palette par make-style.ps1. PAS de rectangle derriere
|
||||
// lui : il en resultait deux cadres arrondis emboites.
|
||||
FSearch := TEdit.Create(Self);
|
||||
FSearch.Parent := LTop;
|
||||
FSearch.Parent := LSearchWrap;
|
||||
FSearch.Align := TAlignLayout.Client;
|
||||
FSearch.OnChangeTracking := OnSearchChanged;
|
||||
|
||||
@@ -460,18 +488,6 @@ begin
|
||||
// Croix d'effacement, montree seulement quand il y a quelque chose a
|
||||
// effacer. Un TLabel et non un bouton : dans un champ, une croix se touche,
|
||||
// elle ne se dessine pas comme une commande.
|
||||
FSearchClear := TLabel.Create(FSearch);
|
||||
FSearchClear.Parent := FSearch;
|
||||
FSearchClear.Align := TAlignLayout.Right;
|
||||
FSearchClear.Width := 44;
|
||||
FSearchClear.Visible := False;
|
||||
FSearchClear.Text := 'X';
|
||||
FSearchClear.TextSettings.HorzAlign := TTextAlign.Center;
|
||||
FSearchClear.TextSettings.VertAlign := TTextAlign.Center;
|
||||
FSearchClear.StyledSettings := [];
|
||||
FSearchClear.TextSettings.Font.Size := 17;
|
||||
FSearchClear.TextSettings.FontColor := COL_MUTED;
|
||||
FSearchClear.OnClick := OnSearchClear;
|
||||
end;
|
||||
|
||||
/// Intitule discret au-dessus d'une valeur. Meme forme pour toutes les
|
||||
|
||||
Reference in New Issue
Block a user