Recent

Author Topic: [SynEdit] Doesn't ReshowTimeout of THintInfo work?  (Read 7224 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
[SynEdit] Doesn't ReshowTimeout of THintInfo work?
« on: February 18, 2015, 12:49:35 pm »
Hello,

i am at implementing OnShowHint for my Synedit class.
But HintInfo.ReshowTimeout does't seem to work. I always have to move the coursor out of the editor to show an other hint.

Or am i doing something wrong here?

Code: [Select]
procedure TEditorFile.ShowHint(Sender: TObject; HintInfo: PHintInfo);
var
  p: TPoint;
begin
  p := HintInfo^.CursorPos;
  p := fEditor.PixelsToLogicalPos(p);
  if (p.x > 0) and (p.y > 0) then
    HintInfo^.HintStr := Format('Cursor at x=%d y=%d', [p.x, p.y])
  else
    HintInfo^.HintStr := '';
  HintInfo^.ReshowTimeout := 500;
end;                                   
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12109
  • Debugger - SynEdit - and more
    • wiki
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #1 on: February 18, 2015, 03:19:43 pm »
Afaik SynEdit does not change any hint specific behaviour. This is all handled by parent classes. Of course it could be that it overrides a method involved into hints.

Does your code work with other controls? TPanel, TLabel?

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #2 on: February 18, 2015, 08:54:40 pm »
Also does not work an TPanel, same behavior!
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12109
  • Debugger - SynEdit - and more
    • wiki
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #3 on: February 18, 2015, 09:29:15 pm »
In that case, you can either:

1) discuss on the mail list to find out if it should. (if none of the conditions on (2) apply)

2) if either
- it is documented that it should
- you do not want to go to the mail list (might be closed if not intended)
- it is missing Delphi compatible (please point out the DOCUMENTATION on Delphi that says so)

go to the bugtracker and raise an issue

Please do not make this about SynEdit in the bugtracker. It is a generic issue. (If it is fixed for TPanel it will likely work for SynEdit, if not, then a 2nd issue needs to be raised then.)

Basile B.

  • Guest
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #4 on: February 18, 2015, 11:55:56 pm »
Could you post (still in this topic )a link to the bug tracker issue once filled ? I'd like to track this particular issue. Thx.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #5 on: February 19, 2015, 07:21:27 am »
The information is found here:
http://docwiki.embarcadero.com/Libraries/XE7/en/Vcl.Controls.THintInfo
In earlier versions it is described as internal.
I will raise an issue in the bugtracker.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #6 on: February 19, 2015, 07:38:08 am »
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Basile B.

  • Guest
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #7 on: February 19, 2015, 07:48:13 am »
Thanks. Actually i have the same issue, in a CustomSynEdit too, the hint is not reshown until either:
- mouse scroll
- click/mouse down in the editor
- mouse move out of an editor

I've given a brief try to found which event is internally called to reset the thing but without any success.

In Lazarus editor there is not the same problem because the authors have coded an independant hint system based on two TIdleTimer (IIRC).

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #8 on: February 19, 2015, 09:13:23 am »
Yes, right, i had a look at the lazarus ide too as it works okay there!
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #9 on: February 19, 2015, 10:26:59 am »
Basile B.,

there is a fix for this issue in Synedit. Have a look at this OnShowHint procedure:

Code: [Select]
procedure TEditorFile.ShowHint(Sender: TObject; HintInfo: PHintInfo);
var
  cp, tp, p1, p2: TPoint;
  r: TRect;
begin
  cp := HintInfo^.CursorPos;
  DebugLn(Format('~~~ ShowHint: cp.x=%d cp.y=%d', [cp.x, cp.y]));
  tp := fEditor.PixelsToLogicalPos(cp);
  if (tp.x > 0) and (tp.y > 0) then
    HintInfo^.HintStr := Format('Cursor at x=%d y=%d', [tp.x, tp.y])
  else
    HintInfo^.HintStr := '';
  p1 := fEditor.RowColumnToPixels(tp);
  DebugLn(Format('~~~ ShowHint: p1.x=%d p1.y=%d', [p1.x, p1.y]));
  tp.x := tp.x+1;
  tp.y := tp.y+1;
  p2 := fEditor.RowColumnToPixels(tp);
  DebugLn(Format('~~~ ShowHint: p2.x=%d p2.y=%d', [p2.x, p2.y]));
  r.Left := p1.x;
  r.Top := p1.y;
  r.Right := p2.x;
  r.Bottom := p2.y;
  HintInfo^.CursorRect := r;

  // TODO: ReshowTimeout funktioniert nicht
  // HintInfo^.ReshowTimeout := 500;
end;

I've set the HintInfo.CursorRect to the char the mouse is on. If the mouse leaves this are the hint is reshown again (this proc is called again for the new cursor position).
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Basile B.

  • Guest
Re: [SynEdit] Doesn't ReshowTimeout of THintInfo work?
« Reply #10 on: February 19, 2015, 11:13:24 am »
Right right right you're right.

By my side I've made this:
Code: [Select]
HintInfo.CursorRect.Left := fDoc.CaretXPix;
HintInfo.CursorRect.Top := fDoc.CaretYPix;

which is somehow similar to what you've shown in the previous post.
Thx. :D
« Last Edit: February 19, 2015, 03:35:02 pm by Basile B. »

 

TinyPortal © 2005-2018