Good morning,
How can I achieve a hover-effect for the items in a TAdvSmoothListBox component ?
I want items to light up when the user hovers the mouse over them. How can I achieve this effect ?
Haven't had a reply to this topic yet. I tried using OnItemMouseEnter and OnItemMouseLeave events, and changing the Selection and FillSelected properties there, but not to my full satisfaction.
Is there a property I am overlooking that enables hover effects somehow ?
Hi,
hovering is not implemented, as the listbox was designed for touch based systems.
You could use the OnItemMouseEnter, OnItemMouseLeave and keep track of the hovered item, then force an invalidate and use the OnItemCustomizeFill event:
var
Form1: TForm1;
hov: Integer = -1;
implementation
{$R *.dfm}
procedure TForm1.AdvSmoothListBox1ItemCustomizeFill(Sender: TObject;
Item: TAdvSmoothListBoxItem; AFill, ADisabledFill, ASelectedFill: TGDIPFill);
begin
if hov = Item.Index then
AFill.Color := clRed;
end;
procedure TForm1.AdvSmoothListBox1ItemMouseEnter(Sender: TObject;
itemindex: Integer);
begin
hov := itemindex;
AdvSmoothListBox1.Invalidate;
end;
procedure TForm1.AdvSmoothListBox1ItemMouseLeave(Sender: TObject;
itemindex: Integer);
begin
hov := -1;
AdvSmoothListBox1.Invalidate;
end;
Kind Regards,
Pieter
Seems to work like a charm, thanks...