Please don't put significant thought into this, but does anybody have a reliable code fragment that will pop up a different hint from a multi-panel status bar, depending on which panel the mouse is over?
Mailing lists / lazarus / 2012-05
Multiple hints for a TStatusBar
4 messages · 3 people · –
- MMark Morgan Lloyd 2
- LLudo Brands 1
- Zzeljko 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Mark Morgan Lloyd wrotePlease don't put significant thought into this, but does anybody have a reliable code fragment that will pop up a different hint from a multi-panel status bar, depending on which panel the mouse is over?
I'm pretty sure that's possible with qt widgetset. Since each panel has QLabel, so QWidget_setToolTip() should work on each panel separatelly. Don't know any LCL solution.
zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120519/482d9161/attachment.html>
Please don't put significant thought into this, but does anybody have a reliable code…
Show quoted text 5 lines
Create an OnMouseMove event handler for the status bar and use the following code:
procedure TForm1.StatusBar1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
i,border:integer;
begin
i:=0;
border:=0;
repeat
border:=border+StatusBar1.Panels[i].Width;
i:=i+1;
until (i=StatusBar1.Panels.Count) or (X<border);
StatusBar1.Hint:='Panel '+IntToStr(i);
application.CancelHint;
application.ActivateHint(mouse.CursorPos);
end;This will show a hint 'Panel 1', 'Panel 2', etc. when you hover over the different panels. Replace StatusBar1.Hint:='Panel '+IntToStr(i); with whatever code to display the hint you like.
The block
application.CancelHint;
application.ActivateHint(mouse.CursorPos);is needed to cancel and retrigger the hint whenever the mouse moves. The Statusbar is one control and moving the mouse from one panel to another without exiting the status bar wouldn't cancel and retrigger the hint.
Tested on windows.
Ludo
Ludo Brands wrote 10 lines
Thanks Ludo, Just what I was looking for. Tested on GTK2 and Qt (Debian "Squeeze", x86).
