-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RichTextBox LinkClicked
event doesn't work for "friendly named" hyperlinks
#1631
Comments
Title might need a fix? The linked article talks about a regression in hyperlinks, not about images.
The linked article suggests that only as a workaround for a regression in WinForms, not because the RTB handles hyperlinks differently. RTB 5.0 has a "friendly name hyperlink" feature which WinForms apparently doesn't understand. So while your argument that downgrading to older RTB controls is no longer possible is true, for the linked problem the "right thing to do" would be to fix the bug in WinForms, not having people work around it by using older RTB versions. |
@RussKie The linked SO question is about I also tried editing an image (PBrush object class) in |
Yes, thank you - looked at the wrong title in the original ticket. |
LinkClicked
event doesn't work for "friendly named" hyperlinks
@RussKie @weltkante It sounds to me like we now use RTB 5.0 and that there is additional work to support functionality new to 5.0 that we have not wrapped appropriately; does that sound right? |
@zsd4yr Yes, thats what the linked stackoverflow article says in the response marked as answer, it's pretty detailed in outlining the problem in the WinForms implementation leading to events not firing. I'll quote a very reduced version here for quick summary but the stackoverflow response linked in the OP is worth a read:
|
Right now we have a broader issue of link clicked events not working at all - #1644 |
#1644 works when initialization is moved from constructor to load event, so its not related to hyperlinks, it seems to be a general pattern that in .NET Core there's a problem when things are initialized in the constructor |
This comment has been minimized.
This comment has been minimized.
@RussKie #1520 is very unclearly formulated, the title does not match with the screenshot, so its not clear why this should be a duplicate. It may very well be that the zip repro attached to #1520 also repros this problem, but that doesn't make #1520 a duplicate if the issue describes something different. If you keep the multiple bugs of #1520 in one issue you'll have to make sure all get fixed before closing. |
We've discussed it with our testers, who have submitted #1520, and it was resolved as reporting the same issue. |
@RussKie considering you said in PR #1661 that Issue #1520 will be fixed by said PR, this issue can't be a duplicate. This repros on Desktop Framework and I'd assume it also repros in .NET Core. Since the bug fixed by PR #1661 never existed in Desktop Framework it can't be the same issue. The problem the stackoverflow article was about is a regression in the Desktop Framework long ago (by updating to a newer version of the RTF control which supported features WinForms doesn't understand). I'd recommend to reopen so this can be fixed at some point. Of course you are free to reprioritize, it might not be necessary to fix for 3.0 since it repros on Desktop Framework by default and the only thing you took away is the known workaround to downgrade the RTF control. (Note for anyone wanting to investigate: the exact location of the bug was already root-caused in the stackoverflow article linked in the issue description, so you don't need to do that yourself again.) using System;
using System.Drawing;
using System.Windows.Forms;
public class Form1 : Form
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private RichTextBox richTextBox1;
public Form1()
{
richTextBox1 = new RichTextBox();
richTextBox1.Dock = DockStyle.Fill;
richTextBox1.LinkClicked += richTextBox1_LinkClicked;
ClientSize = new Size(640, 480);
Controls.Add(richTextBox1);
Load += Form1_Load;
}
private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang4105{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Riched20 10.0.17134}\viewkind4\uc1
{\field{\*\fldinst { HYPERLINK ""http://www.google.com"" }}{\fldrslt {Click here}}}
\pard\sa200\sl276\slmult1\f0\fs22\lang9 for more information.\par
}";
}
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
MessageBox.Show($"link {e.LinkText} clicked");
}
} |
@weltkante thank you for being persistent. |
@JeremyKuhne @Tanya-Solyanik can you think of any implications if we remove the following check? winforms/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs Lines 3498 to 3501 in d989476
I have run few tests with few different rtfs and everything seemed to work. This check was presumably added in response to "VSWhidbey 504502" bug, but I don't know where to find it. |
The newer RichEdit controls (v4.1+) in specific cases had troubles detecting "friendly named" hyperlinks as the `Text` property was reportig less characters than the rage of the actual hyperlink. Fixes dotnet#1631 Relates to dotnet#1139
just like to chime in and say how much of a pain this is, just encountered it in 4.8 desktop winforms app (we are building plugins for Autodesk navisworks/revit) |
Have you tried adding the setting which reverts back to the older RTB in .NET 4.8? If this is a significant problem that the apps config file I would suggest you use VS Feedback to report the problem and tell us how this is impacting the Autodesk app in particular. We can look into what can be done. Though to set expectations, .NET Framework 4.8 is in servicing only mode and the bar for fixes is quite high. It would be good to get this reported though so we can keep track of the impact. |
dotnet --info
)Problem description:
With the removal of the quirk
Switch.System.Windows.Forms.DoNotLoadLatestRichEditControl
(3f2ca8a) we may regress because we will use newer RTB controls (4.0+) and users will no longer be able to load older RTB controls that handled some hyperlinks differently.Please refer to https://stackoverflow.com/q/56936777/2338036
Actual behavior:
Expected behavior:
Minimal repro:
The text was updated successfully, but these errors were encountered: