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 :
Cela peut s’avérer très pratique… néanmoins, par défaut sur tous les composants, c’est rarement utile
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);
Derniers commentaires