Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-05

Multiple hints for a TStatusBar

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

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?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

zeljko
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote
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?

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>

Reply by email

Ludo Brands
to Mark Morgan Lloyd: Please don't put significant thought into this, but does anybody have a reliable code…
Show quoted text 5 lines
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?

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

Reply by email

Mark Morgan Lloyd
to Ludo Brands
Ludo Brands wrote 10 lines
> 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? 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. Tested on windows.

Thanks Ludo, Just what I was looking for. Tested on GTK2 and Qt (Debian "Squeeze", x86).

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email