Profile Picture

Embed special URI in document

Posted By Arthur Butler 7 Years Ago
Author
Message
Arthur Butler
Question Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 1, Visits: 1
I am wanting to embed a link or similar into a document such that when the user clicks on it, my code can bring up a special editor.  For example, we could wrap an image in a URI and then clicking on that URI will call my code to edit that image.  Is something like this possible with your toolset?  Or maybe add a double click callback?  I did not see anything in the documentation.

Thanks,
Arthur

Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi,

Hyperlink inlines inherit from NInputElement, so you can subscribe to any mouse or keyboard event exposed by this class. The following piece of code demonstrates how to create a rich text document that contains a hyperlink, which opens a message box when clicked:

private NDocumentBlock CreateTextDocument()
{
  NDocumentBlock document = new NDocumentBlock();

  // Create a paragraph
  NParagraph paragraph = new NParagraph();
  paragraph.Inlines.Add(new NTextInline("The following is a hyperlink that shows a message box when clicked:"));
  paragraph.Inlines.Add(new NLineBreakInline());

  // Add a hyperlink inline and subscribe to its MouseDown event
  NHyperlinkInline hyperlinkInline = new NHyperlinkInline("Click me to show a message box");
  hyperlinkInline.MouseDown += OnHyperlinkInlineMouseDown;
  paragraph.Inlines.Add(hyperlinkInline);

  // Create a section and add the paragraph to it
  NSection section = new NSection();
  section.Blocks.Add(paragraph);
  document.Sections.Add(section);

  return document;
}

private void OnHyperlinkInlineMouseDown(NMouseButtonEventArgs arg)
{
  if (arg.Button == ENMouseButtons.Left && !arg.Cancel)
  {
   // Show a message box
   NMessageBox.Show("Hyperlink clicked", "Message");

   // Mark the event as handled
   arg.Cancel = true;
  }
}


You can then assign the created document block to the Content property of an NRichTextView instance.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic