Recent

Author Topic: OnLinkAction(...) fails on Windows  (Read 5559 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
OnLinkAction(...) fails on Windows
« on: August 13, 2017, 01:26:19 pm »
OK, another one. I am starting to wonder here a bit, I am finding a lot of problems in what I thought is a stable piece of code. I'm using Lazarus 1.8rc3, should I revert back to 1.6 ?

Anyway, under Windows (Linux works fine), the parameters the OnLinkAction call back arrive with are, apparently random.  Easy demo, drop a RichMemo on a form and make an event handler for OnShow for the form and OnLinkAction for the RichMemo. Make them look like this -

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormShow(Sender: TObject);
  2. var
  3.   FP :  TFontParams;
  4. begin
  5.   FP.Style := [];
  6.   FP.Color := clBlack;
  7.    FP.VScriptPos := vpNormal;
  8.   FP.Size := FontSize;
  9.   RichMemo1.Clear;
  10.   RichMemo1.Append('A Link OK ? ');
  11.   InsertFontText(RichMemo1, 'A Link again.', FP, -1);
  12.   RichMemo1.SetLink(2, 4, True);
  13.   RichMemo1.SetLink(15, 4, True);
  14. end;
  15.  
  16. procedure TForm1.RichMemo1LinkAction(Sender: TObject; ALinkAction: TLinkAction;
  17.   const info: TLinkMouseInfo; LinkStart, LinkLen: Integer);
  18. begin
  19.   Showmessage('clicked ' + inttostr(LinkStart) + ' ' + inttostr(LinkLen));
  20. end;
  21.  

Run it, click one of the "Link". In my case, Start usually comes out as 6 and Len can be anything between -6 and 32K  !

Similarly, the sample project included with RichEdit, "Link" also displays nonsense.

David
« Last Edit: August 13, 2017, 02:46:59 pm by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OnLinkAction(...) fails on Windows
« Reply #1 on: August 13, 2017, 04:54:11 pm »
While SetLink() is present in RichMemo, it's still considered to be under development.

I presume you've a limited set of Widgetset/systems. It's possible to update RichMemo to meet your needs.
What windows do you use?
« Last Edit: August 13, 2017, 04:58:56 pm by skalogryz »

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: OnLinkAction(...) fails on Windows
« Reply #2 on: August 14, 2017, 08:42:58 am »
Ah, "under development" ?
OK, that explains it I guess. Might be a good idea to document that on the Wiki, I assumed it was mature and have spent a long time trying to work out what I was doing wrong.

I am developing a "proof of concept" app, I plan to propose it as a future replacement for another widely used open source project. Its key claim to fame is its cross platform but depending on things like GTK+ libries for windows is becoming a real problem.

I'd need all platforms  :D  Seriously, its a future thing, certainly current versions of windows only, whats that ?  Win10 and Win8 ??

But, in the case of OnLinkAction, I guess I need make a workaround. Looks like the call back works, I can easily find the extent of the link.

So, does this mean the other problems I have been having are 'real' too ?  Should I be putting in bug reports (on bug tracker, under CCR) ?

Would it be useful if I established a (wiki page) table with what I find does work and what is not ?  And perhaps workaround for the ones that don't .....

David
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: OnLinkAction(...) fails on Windows
« Reply #3 on: August 15, 2017, 01:29:37 am »
OK, this works on both gtk2 Linux (Ubuntu) and Win10, I don't have a Mac to test against. Will be testing (for my own reasons) against a number of other Linux distros.

Quote
procedure TForm1.OnLinkAction(Sender: TObject; ALinkAction: TLinkAction;
  const info: TLinkMouseInfo; LinkStart, LinkLen: Integer);
var
  Index, Len : longint;
begin
    Index := RichMemo1.SelStart;
    Len := 0;
    while RichMemo1.IsLink(Index) do dec(Index);
    inc(Index);
    While RichMemo1.isLink(Index + Len) do inc(Len);
    ShowMessage('[' + RichMemo1.GetText(Index, Len) + '] ' + inttostr(Index) + ' ' + inttostr(Len));
end;
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OnLinkAction(...) fails on Windows
« Reply #4 on: August 15, 2017, 02:46:01 am »
Ah, "under development" ?
OK, that explains it I guess. Might be a good idea to document that on the Wiki, I assumed it was mature and have spent a long time trying to work out what I was doing wrong.
well, it's kinda reverse.
If you find a method in TRichMemo, that is not documented on the wiki, then consider it as an experimental feature.
There are a few: SetLink(), InDelInline() and Print().
SetLink is probably the closest for the "release".

Feel free to create a new wiki page or use an existing one, like RichMemo/Features or Internals. (The main RichMemo page got pretty big, it should be split apart)

But, in the case of OnLinkAction, I guess I need make a workaround. Looks like the call back works, I can easily find the extent of the link.
SetLink, should be working just fine for Win7 and later. Thus Win8 and Win10 should work.
On WindowsXP it's possible to make it work, but requires lot more efforts.

So, does this mean the other problems I have been having are 'real' too ? 
I'd think so.
Richmemo follows painware or complainware development model.
I rarely do anything for it to work, but typically tracking anyone start complaining/bug reporting about it.
Once there's an issue, it's being addressed. If I'm lucky, the person reported the issue is still around and can do a good through test of a feature fixed.
(Here's an example of "complain" that typically sparks my interest. It's not directly RichMemo related. However TRichMemo  inherits from TMemo, and thus inherits erratic behavior as well. As you might see, TC didn't stay long enough, thus no actions were taken)

Should I be putting in bug reports (on bug tracker, under CCR) ?
bug reports and/or patches are always welcomed on the bug tracker.

« Last Edit: August 15, 2017, 02:50:18 am by skalogryz »

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: OnLinkAction(...) fails on Windows
« Reply #5 on: August 16, 2017, 01:47:02 am »
OK skalogryz, that all makes sense.
I think I might put the content I am thinking about in the existing 'Features' page but, over time, it could be split up, separating on future features from whats there now.  I plan to have lots of code snippits.  I may also mention the features page higher up in the main RichMemo page too.

And maybe define why a function is mentioned on one page but not the other ?

I don't expect to need support WinXP of even Win7. But maybe I am wrong there, I'm not a Windows user so no real feel for what people want. Do need support lots of Linux platforms. And Mac ...

I am currently testing my ap on several platforms, seeing some unexpected divergence on various linux systems (surprise, surprise !) so once I have a good feel of where it all is I'll put together those bug reports, with diff files too I suppose ?

Thanks skalogryz, I really appreciate the work you have put into this component, hope I can help in a small way to make it better still.

David


Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018