Message Boards Message Boards

1
|
8216 Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Constructing palette that replaces selection with link to documentation

Posted 10 years ago

Hello,

I am hoping that someone with more experience than I can provide a quick example of how to create a simple palette. I know I should read the documentation to do this, but a simple working example is all I need.

I'd like to be able to select text from within a text cell, and then have a palette button replace the selection with a Hyperlink to the documentation.

For example, if the word HistogramList were selected, then that selection would be replaced with a ButtonBox:

ButtonBox["HistogramList", BaseStyle->"Link", ButtonData->"paclet:ref/HistogramList"]

and then I would install this as a palette for later use.

Thanks, WCC

POSTED BY: W. Craig Carter
4 Replies

I would like to additionally point out that if there is a Function name in a text or Section cell and one places the cursor in or just after it, or if it is selected, then the F1 key or the "Find selected Function" item in the Help menu will bring up the relevant Help page.

Thank you David and Mohamad,

David's suggestion works for the problem I had in mind: I am constructing student notebooks with text cells and wish to build in links to the documentation where I discuss a particular function.

POSTED BY: W. Craig Carter

Try this Craig.

generateWRILink[] :=
 Module[{routineName, buttonText, button},
  routineName = NotebookRead[EvaluationNotebook[]];
  buttonText = "paclet:ref/" <> routineName;
  button = 
   ButtonBox[routineName, BaseStyle -> "Link", 
    ButtonData -> buttonText];
  NotebookWrite[EvaluationNotebook[], button]
  ]

Button["Make Link", generateWRILink[]]

Hello,

You can try this method. First run the code:

Framed[DisplayForm[ButtonBox["HistogramList", BaseStyle -> "Link", ButtonData -> "paclet:ref/HistogramList"]]]

then:

1) Select the output cell

2) Open Palettes button

enter image description here

this is example palette that I have created

enter image description here

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract