View Issue Details

IDProjectCategoryView StatusLast Update
0005759JEDI VCL00 JVCL Componentspublic2012-09-10 14:15
ReporterZENsanAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.46 
Summary0005759: Cell hint is shown in wrong position
DescriptionWhen ShowCellHint = True hint is shown always in the top left point of the cell and not at the mouse cursor position.

Why it is performed this way?
    if not AtCursorPosition and HintWindowClass.ClassNameIs('THintWindow') then
      HintPos := ClientToScreen(CursorRect.TopLeft);
Why not Mouse.CursorPos?

I think hint must drop down where is mouse cursor andnot in the another side of the screen (if cell is bigger than 16 pixels...).
TagsNo tags attached.

Activities

ZENsan

2012-01-05 08:15

reporter   ~0019299

I forgot to tell.. :) It's JvDBGrid.pas, sorry.

2012-01-06 09:02

 

JvDBGrid.pas.patch (391 bytes)
Index: JvDBGrid.pas
===================================================================
--- JvDBGrid.pas	(revision 13188)
+++ JvDBGrid.pas	(working copy)
@@ -4555,7 +4555,7 @@
     end;
 
     if not AtCursorPosition and HintWindowClass.ClassNameIs('THintWindow') then
-      HintPos := ClientToScreen(CursorRect.TopLeft);
+      HintPos := Mouse.CursorPos;
   end;
   inherited;
 end;
JvDBGrid.pas.patch (391 bytes)

ZENsan

2012-01-16 09:18

reporter   ~0019316

Hello!
Is there someone alive? :) Just check a patch and apply it if it is correct.

ZENsan

2012-02-12 15:15

reporter   ~0019393

Or probably we can invent a property (bicycle :) ) for defining how hint is displayed - below mouse cursor or in the top-left corner of grid. I just checked how it is in DC++ (RevConnect) software - they display the hint in top-left corner.
So maybe a property like:
  TJvGridCellHintPosition = (chpDefault, chpMouse);
And then in appropriate place we select how to display the hint.

obones

2012-02-22 15:10

administrator   ~0019464

Please provide the zipped sources of a sample application showing this

2012-02-22 15:45

 

Hint.png (22,875 bytes)
Hint.png (22,875 bytes)

2012-02-22 15:45

 

HintIssue.zip (1,560 bytes)

ZENsan

2012-02-22 15:46

reporter   ~0019475

When you move mouse over the right corner of the first cell, hint is popped up at top left corner. Which maybe is a default of course, but sometimes is very weird.
Just read my comment about possible property..

Arioch

2012-02-22 21:54

developer   ~0019480

Truly, i disliek how most GUI libraries tend to use Mouse.Pos.

Win32 plain API was much more correct here.

For many times i saw some application frozen for a second or two, and then menu or hint popped up at completely different place (since mouse moved suring those seconds)

I would also say that there are large cursorls, like those by Stardock CursorFX, so that hints "under cursor" got really hidden by that very cursor.
I do not know if complete and reliable solution can be made in frames of VCL, but it is not just so easy...

Regarding this particular case, i suspect the goal of hint was not just to react to mouse, but to show the complete cell value, when it is too narrow to render the whole text. Cell may display like "abcd...xyz" while the hint would render the hole alphabet. From this POV following mouse cursor is not that obvious choice.

ZENsan

2012-02-23 07:22

reporter   ~0019481

That's why I suggested the property for that choice. And by default make it as it was before.

2012-03-07 07:36

 

Property solution - JvDBGrid.pas.patch (2,685 bytes)
Index: JvDBGrid.pas
===================================================================
--- JvDBGrid.pas	(revision 13188)
+++ JvDBGrid.pas	(working copy)
@@ -104,6 +104,7 @@
   {$ENDIF BCB}
 
   TJvDBGridColumnResize = (gcrNone, gcrGrid, gcrDataSet);
+  TJvDBGridCellHintPosition = (gchpDefault, gchpMouse);
 
   TSelectColumn = (scDataBase, scGrid);
   TTitleClickEvent = procedure(Sender: TObject; ACol: Longint;
@@ -291,6 +292,7 @@
     FRowResize: Boolean;
     FRowsHeight: Integer;
     FTitleRowHeight: Integer;
+    FCellHintPosition: TJvDBGridCellHintPosition;
     FCanDelete: Boolean;
 
     { Cancel edited record on mouse wheel or when resize column (double-click)}
@@ -591,6 +593,10 @@
       default JvGridResizeProportionally;
     property SelectColumnsDialogStrings: TJvSelectDialogColumnStrings
       read FSelectColumnsDialogStrings write SetSelectColumnsDialogStrings;
+
+    { Determines how cell hint position is calculated Mantis #5759, check TJvDBGrid.CMHintShow }
+    property CellHintPosition: TJvDBGridCellHintPosition read FCellHintPosition write FCellHintPosition default gchpDefault;
+
     { Allows user to delete things using the "del" key }
     property CanDelete: Boolean read FCanDelete write FCanDelete default True;
 
@@ -4452,11 +4458,15 @@
   ACol, ARow, ATimeOut, SaveRow: Integer;
   AtCursorPosition: Boolean;
   CalcOptions: Integer;
+  InitialMousePos: TPoint;
   HintRect: TRect;
 begin
   AtCursorPosition := True;
   with Msg.HintInfo^ do
   begin
+    { Save the position of mouse cursor }
+    InitialMousePos := Mouse.CursorPos;
+
     HintStr := GetShortHint(Hint);
     ATimeOut := HideTimeOut;
     Self.MouseToCell(CursorPos.X, CursorPos.Y, ACol, ARow);
@@ -4491,7 +4501,7 @@
 
     if FShowTitleHint and (ACol >= 0) and (ARow <= -1) then
     begin
-      AtCursorPosition := False;
+      AtCursorPosition := FCellHintPosition = gchpMouse;
       HintStr := Columns[ACol].FieldName;
       ATimeOut := Max(ATimeOut, Length(HintStr) * C_TIMEOUT);
       if Assigned(FOnShowTitleHint) and DataLink.Active then
@@ -4502,7 +4512,7 @@
     if FShowCellHint and (ACol >= 0) and DataLink.Active and
       ((ARow >= 0) or not FShowTitleHint) then
     begin
-      AtCursorPosition := False;
+      AtCursorPosition := FCellHintPosition = gchpMouse;
       HintStr := Hint;
       SaveRow := DataLink.ActiveRecord;
       try
@@ -4555,7 +4565,9 @@
     end;
 
     if not AtCursorPosition and HintWindowClass.ClassNameIs('THintWindow') then
-      HintPos := ClientToScreen(CursorRect.TopLeft);
+      HintPos := ClientToScreen(CursorRect.TopLeft)
+    else
+      HintPos := InitialMousePos;
   end;
   inherited;
 end;

ZENsan

2012-03-07 07:37

reporter   ~0019651

I uploaded "Property solution - JvDBGrid.pas.patch". There I added a published property named CellHintPosition of type TJvDBGridCellHintPosition (gchpDefault, gchpMouse), by default it is as it was before. But now if you set to gchpMouse then hint appears under mouse cursor.

obones

2012-06-12 13:40

administrator   ~0019912

Thanks, this is now in SVN

Issue History

Date Modified Username Field Change
2012-01-03 15:44 ZENsan New Issue
2012-01-05 08:15 ZENsan Note Added: 0019299
2012-01-06 09:02 ZENsan File Added: JvDBGrid.pas.patch
2012-01-16 09:18 ZENsan Note Added: 0019316
2012-02-12 15:15 ZENsan Note Added: 0019393
2012-02-22 15:10 obones Note Added: 0019464
2012-02-22 15:10 obones Status new => feedback
2012-02-22 15:45 ZENsan File Added: Hint.png
2012-02-22 15:45 ZENsan File Added: HintIssue.zip
2012-02-22 15:46 ZENsan Note Added: 0019475
2012-02-22 21:54 Arioch Note Added: 0019480
2012-02-23 07:22 ZENsan Note Added: 0019481
2012-03-07 07:36 ZENsan File Added: Property solution - JvDBGrid.pas.patch
2012-03-07 07:37 ZENsan Note Added: 0019651
2012-06-11 17:15 obones Status feedback => acknowledged
2012-06-12 13:40 obones Note Added: 0019912
2012-06-12 13:40 obones Status acknowledged => resolved
2012-06-12 13:40 obones Fixed in Version => Daily / SVN
2012-06-12 13:40 obones Resolution open => fixed
2012-06-12 13:40 obones Assigned To => obones
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46