fix(android): the folder panel closes when you tap beside it
It stayed open until something was chosen, and there was no way to change your mind. A full-screen scrim now dims the background and takes the outside tap; the hardware back button closes the panel before anything else, which is what it is expected to do while something is open. The list also scrolls: eight folders fit, twenty would have run off the screen. Rows are placed by coordinate inside the scroll box, with no alignment at all - the only arrangement FMX has not surprised me with today. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+46
-12
@@ -741,6 +741,14 @@ procedure TForm8.OnHardwareBack(Sender: TObject; var Key: Word;
|
|||||||
var KeyChar: WideChar; Shift: TShiftState);
|
var KeyChar: WideChar; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if Key <> vkHardwareBack then Exit;
|
if Key <> vkHardwareBack then Exit;
|
||||||
|
// Le panneau des dossiers se ferme avant tout le reste : c'est ce que le
|
||||||
|
// bouton retour est cense faire d'abord quand quelque chose est ouvert.
|
||||||
|
if FFolderPanel <> nil then
|
||||||
|
begin
|
||||||
|
FreeAndNil(FFolderPanel);
|
||||||
|
Key := 0;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
if FLayDetail.Visible then
|
if FLayDetail.Visible then
|
||||||
begin
|
begin
|
||||||
ShowList;
|
ShowList;
|
||||||
@@ -1181,33 +1189,59 @@ procedure TForm8.OnFolderTap(Sender: TObject);
|
|||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
LRow: TRectangle;
|
LRow: TRectangle;
|
||||||
LH: Single;
|
LCard: TRectangle;
|
||||||
|
LBody: TVertScrollBox;
|
||||||
|
LH, LWanted, LMax: Single;
|
||||||
begin
|
begin
|
||||||
Touch;
|
Touch;
|
||||||
FreeAndNil(FFolderPanel);
|
FreeAndNil(FFolderPanel);
|
||||||
if Length(FFolderNames) < 2 then Exit; // rien a choisir
|
if Length(FFolderNames) < 2 then Exit; // rien a choisir
|
||||||
|
|
||||||
LH := 54;
|
LH := 52;
|
||||||
// PLACEMENT EXPLICITE, aucune convention d'alignement : l'ordre d'empilement
|
|
||||||
// de FMX s'est revele instable des qu'on detruit et recree des enfants.
|
// Voile plein ecran : il assombrit le fond ET recoit le clic exterieur.
|
||||||
FFolderPanel := Surface(FLayList);
|
// Sans lui le panneau restait ouvert tant qu'on n'avait pas choisi - il
|
||||||
FFolderPanel.Align := TAlignLayout.None;
|
// faut toujours pouvoir renoncer.
|
||||||
FFolderPanel.SetBounds(16, 66, FLayList.Width - 32,
|
FFolderPanel := TRectangle.Create(FLayList);
|
||||||
Length(FFolderNames) * LH + 12);
|
FFolderPanel.Parent := FLayList;
|
||||||
FFolderPanel.Fill.Color := COL_SURFACE;
|
FFolderPanel.Align := TAlignLayout.Contents;
|
||||||
|
FFolderPanel.Fill.Color := TAlphaColor($99000000);
|
||||||
|
FFolderPanel.Stroke.Kind := TBrushKind.None;
|
||||||
|
FFolderPanel.OnClick := OnFolderPick;
|
||||||
|
FFolderPanel.Tag := -1; // -1 : renoncer, garder le choix courant
|
||||||
|
|
||||||
|
LWanted := Length(FFolderNames) * LH + 12;
|
||||||
|
LMax := FLayList.Height - 140;
|
||||||
|
if LWanted > LMax then LWanted := LMax;
|
||||||
|
|
||||||
|
LCard := Surface(FFolderPanel);
|
||||||
|
LCard.Align := TAlignLayout.None;
|
||||||
|
LCard.SetBounds(16, 66, FLayList.Width - 32, LWanted);
|
||||||
|
|
||||||
|
// Defilant, car une longue liste de dossiers sortirait de l'ecran. Les
|
||||||
|
// lignes y sont POSEES A LA COORDONNEE, sans alignement : c'est ce qui rend
|
||||||
|
// l'ordre independant des conventions de FMX, instables des qu'on detruit
|
||||||
|
// et recree des enfants.
|
||||||
|
LBody := TVertScrollBox.Create(LCard);
|
||||||
|
LBody.Parent := LCard;
|
||||||
|
LBody.Align := TAlignLayout.Client;
|
||||||
|
LBody.Margins.Rect := RectF(6, 6, 6, 6);
|
||||||
|
LBody.ShowScrollBars := False;
|
||||||
|
|
||||||
for I := 0 to High(FFolderNames) do
|
for I := 0 to High(FFolderNames) do
|
||||||
begin
|
begin
|
||||||
LRow := FlatButton(FFolderPanel, FFolderNames[I], OnFolderPick, I = FFolderSel);
|
LRow := FlatButton(LBody, FFolderNames[I], OnFolderPick, I = FFolderSel);
|
||||||
LRow.Align := TAlignLayout.None;
|
LRow.Align := TAlignLayout.None;
|
||||||
LRow.SetBounds(6, 6 + I * LH, FFolderPanel.Width - 12, LH - 6);
|
LRow.SetBounds(0, I * LH, LCard.Width - 24, LH - 6);
|
||||||
LRow.Tag := I;
|
LRow.Tag := I;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm8.OnFolderPick(Sender: TObject);
|
procedure TForm8.OnFolderPick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if Sender is TRectangle then FFolderSel := TRectangle(Sender).Tag;
|
// Tag -1 : le voile, donc un clic a cote. On ferme sans rien changer.
|
||||||
|
if (Sender is TRectangle) and (TRectangle(Sender).Tag >= 0) then
|
||||||
|
FFolderSel := TRectangle(Sender).Tag;
|
||||||
SetButtonText(FBtnFolder, FFolderNames[FFolderSel]);
|
SetButtonText(FBtnFolder, FFolderNames[FFolderSel]);
|
||||||
FreeAndNil(FFolderPanel);
|
FreeAndNil(FFolderPanel);
|
||||||
OnSearchChanged(nil);
|
OnSearchChanged(nil);
|
||||||
|
|||||||
Reference in New Issue
Block a user