• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Font options in Multi-Line Text fields

LEGEND ,
May 22, 2007 May 22, 2007

Copy link to clipboard

Copied

I think I know the answer to this one but I want to check before I tell someone it can't be done.

One of our developers is producing a help file that contains code snippets in a multi-line text form element inside a form. He wants to be able to format the code to have different colours on different lines but I've not found a way of doing this without affecting ALL the code in the field. Does anyone know a way around this?

Views

704

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 29, 2007 May 29, 2007
OK. I've managed to work out a Javascript option that works and am posting here for anyone's future reference. First off, genererate a single cell table and format the text (code snippet ) as required. Next create a form containing a button and a multi-line text field. In the <HEAD> section paste:

<script LANGUAGE=JavaScript
type="text/javascript">function copy2Clipboard(element)
{
element.select(); // Only works for text boxes.
textRange = document.selection.createRange();
textRange.execComman...

Votes

Translate

Translate
LEGEND ,
May 22, 2007 May 22, 2007

Copy link to clipboard

Copied

Hi Colum

I think that with these beasties, it's all or nothing. I think any application of coloring will affect the content of the entire field.

Cheers... Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 22, 2007 May 22, 2007

Copy link to clipboard

Copied

Yep...thought so. Thanks for confirming Rick. This whole episode came about because the developer originally had the code is an ordinary table cell. Trouble was that when you copy and paste from a table cell you get an additional carriage return at the end of each line. The only way around this that I found was using the multiline text field.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 22, 2007 May 22, 2007

Copy link to clipboard

Copied

Hi again Colum

Is this inside a .CHM file? While it would mean more work for you, I've developed some JavaScript code that allows me to click a word and have desired text automagickally copied to the Windows clipboard. Wondering if that could help here.

If it's WebHelp, I'm doubtful it would work. Might in IE, but would probably fail in others. Or, you could do both. Use the table cell for the color coding display, then insert the text field to store the contents of what you wish to copy. Then on click have some script that selects the text so all they do is press ctrl+C to copy it.

Just some thoughts from a bald midwestern madman on a humid Tuesday morning... Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 23, 2007 May 23, 2007

Copy link to clipboard

Copied

Hi Rick. Hope you've not melted by now . I was talking - well ok drinking - with Peter last night who mentioned the "link" button you guys use in RoboKnowledge. Is this what you were referring to? It sounds promising as it is a CHM file we are dealing with here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2007 May 29, 2007

Copy link to clipboard

Copied

LATEST
OK. I've managed to work out a Javascript option that works and am posting here for anyone's future reference. First off, genererate a single cell table and format the text (code snippet ) as required. Next create a form containing a button and a multi-line text field. In the <HEAD> section paste:

<script LANGUAGE=JavaScript
type="text/javascript">function copy2Clipboard(element)
{
element.select(); // Only works for text boxes.
textRange = document.selection.createRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Copy");
}</script>

Change the button properties to Control Type = Plain Button, Button Caption = Copy to Clipboard, Control Identifier – Delete the default value to leave a blank field. Also add Add onclick="copy2Clipboard(namehere)" to the end of your <input type=submit value=Button> statement.

Change the multi-line text field properties to Control Identifier = namehere (where namehere is the value you specified above), Initial text = Paste the code snippet to be copied to the PC clipboard. Also add style="height: 1px; width: 0px;" to the end of the multi-line text area code.

Note: If the above style statement is set to style="height: 0px; width: 0px;"> a bug generates acres of blank space between the end of the multi-line text box and any other following content. If the multi-line text box is the last part of the topic content this is OK but otherwise the code above must be used.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp