Oct 18

Par défaut, FireMonkey a une propriété activée qui s’appelle EnableDragHighlight.

Cette propriété permet d’entourer par défaut le composant où elle est activée par un carré bleu lorsqu’un élément est glisser au-dessus de lui :

carré bleu : EnableDragHighlight

carré bleu : EnableDragHighlight

Cela peut s’avérer très pratique… néanmoins, par défaut sur tous les composants, c’est rarement utile (mm)

Afin d’éviter d’avoir à modifier la propriété sur chacun de mes composants de mes fenêtres et styles, j’ai rapidement écrit ce bout de code :

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
unit uFMX;

interface

uses
  FMX.Types, System.TypInfo;

procedure SetDragHighlights(const parent: TFmxObject; const enabled: Boolean = False); overload;

implementation

procedure SetDragHighlights(const parent: TFmxObject; const enabled: Boolean); overload;
var
  iLoop, iMax: Integer;
begin
  // Do "parent" have this property?
  if IsPublishedProp(parent, 'EnableDragHighlight') then
  begin
    SetPropValue(parent, 'EnableDragHighlight', enabled);
  end;

  // Do "parent"'s children have it?
  iMax := Pred(parent.ChildrenCount);
  for iLoop := 0 to iMax do
  begin
    SetDragHighlights(parent.Children[iLoop], enabled);
  end;
end;

end.

Je l’appelle à la création d’une fenêtre et lorsqu’un style est appliqué ainsi :

SetDragHighlights(Self);

Share

Lien permanent vers FMX & EnableDragHighlight Rédigé par Whiler \\ Tags : , ,

Laisser une réponse

(requis)

(requis)

*

;) (lol) (y) |-( (hi) 8-) (angel) :s (clap) (bow) (tmi) (:| plus »

This site uses Akismet to reduce spam. Learn how your comment data is processed.