mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 17:40:40 +02:00
Grids: fix grid hints inconsistency, patch from Joeny Ang, issue #35453
git-svn-id: trunk@61184 -
This commit is contained in:
parent
7b47fad549
commit
30f5f0b09d
@ -1668,7 +1668,8 @@ begin
|
|||||||
Result := F.DisplayText
|
Result := F.DisplayText
|
||||||
else
|
else
|
||||||
Result := '(blob)';
|
Result := '(blob)';
|
||||||
if Assigned(OnGetCellHint) then begin
|
// pass to OnGetCellHint() only if chpTruncOnly
|
||||||
|
if Assigned(OnGetCellHint) and (CellHintPriority = chpTruncOnly) then begin
|
||||||
C := ColumnFromGridColumn(ACol) as TColumn;
|
C := ColumnFromGridColumn(ACol) as TColumn;
|
||||||
FOnGetCellHint(self, C, Result);
|
FOnGetCellHint(self, C, Result);
|
||||||
end;
|
end;
|
||||||
|
@ -3953,16 +3953,12 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if ([goCellHints, goTruncCellHints]*Options = []) then
|
if not ShowHint then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
cell := MouseToCell(APoint);
|
cell := MouseToCell(APoint);
|
||||||
if (cell.x = -1) or (cell.y = -1) then
|
if (cell.x = -1) or (cell.y = -1) then
|
||||||
begin
|
|
||||||
Hint := FSavedHint;
|
|
||||||
Application.Hint := GetLongHint(FSavedHint);
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
|
||||||
|
|
||||||
txt1 := ''; // Hint returned by OnGetCellHint
|
txt1 := ''; // Hint returned by OnGetCellHint
|
||||||
txt2 := ''; // Hint returned by GetTruncCellHintText
|
txt2 := ''; // Hint returned by GetTruncCellHintText
|
||||||
@ -3970,7 +3966,7 @@ begin
|
|||||||
txt := ''; // Hint to be displayed as popup
|
txt := ''; // Hint to be displayed as popup
|
||||||
PrepareCellHints(cell.x, cell.y); // in DBGrid, set the active record to cell.y
|
PrepareCellHints(cell.x, cell.y); // in DBGrid, set the active record to cell.y
|
||||||
try
|
try
|
||||||
if (goCellHints in Options) then
|
if (goCellHints in Options) and (FCellHintPriority <> chpTruncOnly) then
|
||||||
txt1 := GetCellHintText(cell.x, cell.y);
|
txt1 := GetCellHintText(cell.x, cell.y);
|
||||||
if (goTruncCellHints in Options) then begin
|
if (goTruncCellHints in Options) then begin
|
||||||
txt2 := GetTruncCellHintText(cell.x, cell.y);
|
txt2 := GetTruncCellHintText(cell.x, cell.y);
|
||||||
@ -3987,31 +3983,24 @@ begin
|
|||||||
case FCellHintPriority of
|
case FCellHintPriority of
|
||||||
chpAll:
|
chpAll:
|
||||||
begin
|
begin
|
||||||
AddToHint(txt, txt1);
|
AddToHint(txt, GetShortHint(FSavedHint));
|
||||||
|
AddToHint(txt, GetShortHint(txt1));
|
||||||
AddToHint(txt, txt2);
|
AddToHint(txt, txt2);
|
||||||
if (txt <> '') then begin
|
AddToHint(AppHint, GetLongHint(FSavedHint));
|
||||||
if FSavedHint = '' then
|
AddToHint(AppHint, GetLongHint(txt1));
|
||||||
AppHint := txt
|
|
||||||
else begin
|
|
||||||
txt := GetShortHint(FSavedHint) + LineEnding + txt;
|
|
||||||
AppHint := GetLongHint(FSavedHint) + LineEnding + txt;
|
|
||||||
end;
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
txt := GetShortHint(FSavedHint);
|
|
||||||
AppHint := GetLongHint(FSavedHint);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
chpAllNoDefault:
|
chpAllNoDefault:
|
||||||
begin
|
begin
|
||||||
AddToHint(txt, txt1);
|
AddToHint(txt, GetShortHint(txt1));
|
||||||
AddToHint(txt, txt2);
|
AddToHint(txt, txt2);
|
||||||
AppHint := txt;
|
AddToHint(AppHint, GetLongHint(txt1));
|
||||||
end;
|
end;
|
||||||
chpTruncOnly:
|
chpTruncOnly:
|
||||||
begin
|
begin
|
||||||
AddToHint(txt, txt2);
|
AddToHint(txt, txt2);
|
||||||
AppHint := txt;
|
AppHint := txt;
|
||||||
|
if Pos('|', AppHint) = 0 then
|
||||||
|
AppHint := AppHint + '|';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4021,7 +4010,7 @@ begin
|
|||||||
if (AppHint = '') then AppHint := FSavedhint;
|
if (AppHint = '') then AppHint := FSavedhint;
|
||||||
*)
|
*)
|
||||||
|
|
||||||
if (txt <> '') and not EditorMode and not (csDesigning in ComponentState) then begin
|
if not EditorMode and not (csDesigning in ComponentState) then begin
|
||||||
Hint := txt;
|
Hint := txt;
|
||||||
//set Application.Hint as well (issue #0026957)
|
//set Application.Hint as well (issue #0026957)
|
||||||
Application.Hint := GetLongHint(AppHint);
|
Application.Hint := GetLongHint(AppHint);
|
||||||
@ -6752,13 +6741,19 @@ begin
|
|||||||
AllowOutboundEvents := obe;
|
AllowOutboundEvents := obe;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//if we are not over a cell, and we use cellhint, we need to empty Application.Hint
|
// if we are not over a cell
|
||||||
if (p.X < 0) and ([goCellHints, goTruncCellHints]*Options <> []) and
|
if p.X < 0 then
|
||||||
(FCellHintPriority <> chpAll)
|
begin
|
||||||
then begin
|
// empty hints
|
||||||
Application.Hint := '';
|
Application.Hint := '';
|
||||||
Hint := '';
|
Hint := '';
|
||||||
end;
|
// if FCellHintPriority = chpAll, restore default hint
|
||||||
|
if ShowHint and (FCellHintPriority = chpAll) then
|
||||||
|
begin
|
||||||
|
Hint := FSavedHint;
|
||||||
|
Application.Hint := GetLongHint(FSavedHint);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
with FGCache do
|
with FGCache do
|
||||||
if (MouseCell.X <> p.X) or (MouseCell.Y <> p.Y) then begin
|
if (MouseCell.X <> p.X) or (MouseCell.Y <> p.Y) then begin
|
||||||
@ -8072,12 +8067,14 @@ procedure TCustomGrid.CMMouseEnter(var Message: TLMessage);
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
FSavedHint := Hint;
|
FSavedHint := Hint;
|
||||||
|
// Note: disable hint when entering grid's border, we'll manage our own hints
|
||||||
|
Application.Hint := '';
|
||||||
|
Application.CancelHint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.CMMouseLeave(var Message: TLMessage);
|
procedure TCustomGrid.CMMouseLeave(var Message: TLMessage);
|
||||||
begin
|
begin
|
||||||
if [goCellHints, goTruncCellHints] * Options <> [] then
|
Hint := FSavedHint;
|
||||||
Hint := FSavedHint;
|
|
||||||
ResetHotCell;
|
ResetHotCell;
|
||||||
inherited CMMouseLeave(Message);
|
inherited CMMouseLeave(Message);
|
||||||
end;
|
end;
|
||||||
@ -8554,6 +8551,8 @@ end;
|
|||||||
function TCustomGrid.GetTruncCellHintText(ACol, ARow: Integer): string;
|
function TCustomGrid.GetTruncCellHintText(ACol, ARow: Integer): string;
|
||||||
begin
|
begin
|
||||||
Result := GetCells(ACol, ARow);
|
Result := GetCells(ACol, ARow);
|
||||||
|
if Assigned(FOnGetCellHint) and (FCellHintPriority = chpTruncOnly) then
|
||||||
|
FOnGetCellHint(self, ACol, ARow, result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.GetCells(ACol, ARow: Integer): string;
|
function TCustomGrid.GetCells(ACol, ARow: Integer): string;
|
||||||
|
Loading…
Reference in New Issue
Block a user