Recent

Author Topic: Hint showing outside of TListBox rect  (Read 428 times)

ddev

  • New Member
  • *
  • Posts: 17
Hint showing outside of TListBox rect
« on: January 15, 2021, 01:46:33 am »
I have a TListBox with some lines that are not visible and curiously when I use a hint, the hint is visible OUTSIDE the rect, as can be seen from the attached screen capture. In fact the hint appears up to the last non visible line (if I have two non visibles lines, the hint will not show when I move the cursor downward at a distance higher than the two non visible lines).

Here is the code that generates this form:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     ListBox1: TListBox;
  16.     procedure FormCreate(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.  
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29. procedure TForm1.FormCreate(Sender: TObject);
  30. begin
  31.   ListBox1.Items.add('1');
  32.   ListBox1.Items.add('2');
  33.   ListBox1.Items.add('3');
  34.   ListBox1.Items.add('4');
  35.   ListBox1.Items.add('5');
  36.   ListBox1.Items.add('6');
  37.   ListBox1.Items.add('7');
  38.   ListBox1.ShowHint := true;
  39.   ListBox1.Hint := 'TListBox hint out of rect...';
  40. end;
  41. end.
  42.  

My question then is: how do I limit hints for a TlistBox to its rect?

Lazarus 2.0.10
FPC 3.2.0
Mac OS X 10.14.6
Lazarus 2.0.10
FPC 3.2.0
Mac OS X 10.14.6

speter

  • Full Member
  • ***
  • Posts: 161
Re: Hint showing outside of TListBox rect
« Reply #1 on: January 15, 2021, 02:02:52 am »
Hmmm, interesting. :)

For what little it is worth, this does NOT happen (for me) in windows 10. The hint only shows when within the listbox.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1275
  • Former Delphi 1-7, 10.2 User
Re: Hint showing outside of TListBox rect
« Reply #2 on: January 15, 2021, 02:03:46 am »
Confirmed also in Lazarus 2.1.0 r64368 FPC 3.3.1 x86_64-darwin-cocoa. I suggest you log a bug.
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48688  macOS 11.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

ddev

  • New Member
  • *
  • Posts: 17
Re: Hint showing outside of TListBox rect
« Reply #3 on: January 15, 2021, 06:16:15 pm »
Thanks speter and trev!

Bug reported https://bugs.freepascal.org/view.php?id=38362
Lazarus 2.0.10
FPC 3.2.0
Mac OS X 10.14.6

ddev

  • New Member
  • *
  • Posts: 17
Re: Hint showing outside of TListBox rect
« Reply #4 on: January 15, 2021, 09:09:48 pm »
FWIW I found a partial workaround, blocking the hint when the cursor is below the TListBox rect:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.ListBox1ShowHint(Sender: TObject; HintInfo: PHintInfo);
  2. begin
  3.   if HintInfo^.CursorPos.y > HintInfo^.CursorRect.Bottom then
  4.     application.cancelhint;
  5.  

Problem is that in order for this to work, the TListBox control should have been created AFTER any other controls on the form located below the current TListBox, in the zone where invisible lines should appear. So the order of creation matters here!
« Last Edit: January 16, 2021, 01:05:17 am by ddev »
Lazarus 2.0.10
FPC 3.2.0
Mac OS X 10.14.6

 

TinyPortal © 2005-2018