NRichTextLabel mnemonic and font support


https://www.nevron.com/Forum/Topic9021.aspx
Print Topic | Close Window

By Craig Swearingen - 9 Years Ago
1) When I use an NRichTextLabel I've noticed that it doesn't honor its Font property.  It's using a different font.  When I put both a Label and an NRichTextLabel on my Form which has the same text string in it I can see it looks different.  When I change the text in the NRichTextLabel to be "<font size='8.25' face='Microsoft Sans Serif'>my comparison string</font>" thinking this is the same font as the Label is using while it does look similar its spreading the string out much further than the Label does.  Am I coding the size and face values correctly?

2) A common feature in a Label control is to use the ampersand(&Wink character to denote the mnemonic. When the user presses the Alt+mnemonic character focus goes to the control after the Label.  Is this support a part of the NRichTextLabel?  I was also looking at the NEntryContainer and I suspect it uses an NRichTextLabel for its label portion.  In the Nevron C# Examples program the toolkit provides it has an "Entry Controls" subtree showing two nice looking forms using the NEntryContainer but in a complete UX these forms would need mnemonic support.  Is there some way to accomplish this on those forms?
By Nevron Support - 9 Years Ago
Hello Craig,

To apply font to NRichTextLabel you need to set the following property:
NRichTextLabel.Item.Style.FontInfo

To be able to set a mnemonic character you need to switch the TextRenderMode to GDIPlus:
NRichTextLabel.Item.Style.TextRenderMode = TextRenderMode.GdiPlus

Yes, NEntryContainer is NRichTextLabel, so you can set its label to have mnemonic character as described above.
NEntryContainer.Item.Style.TextRenderMode = TextRenderMode.GdiPlus;

I hope this helps.
By Craig Swearingen - 9 Years Ago
Thanks for responding.  Good to know.  I had missed seeing those properties on the Item.Style property.

1) When setting the Item.Style.FontInfo values to be the same my Label is using with the same text string I see it using the same font but it draws the text string out longer.  It seems like a different drawing engine must be used. (Update: Ahh, I see.  It's the difference between specifying Gdi and GdiPlus.  I get it now.)

2) When using GdiPlus I can see the ampersand character is used to underline the character after it visually like I was looking for.  However, when pressing Alt+<mnemonic> I hear a beep and focus doesn't move to the field after it like a Label control does.  Is this a bug or am I expected to implement that support myself? 

3) Also, I was inspired by the Nevron "Extended Entry Controls" example your toolkit provides which uses the NEntryElement with rich text labels to show a red asterisk character with the text prompt but I need to show a mnemonic and have the Alt+<mnemonic> key work along with a red asterisk.  Can it be configured to do this?
By Craig Swearingen - 9 Years Ago
My previous forum reply seems to have gotten lost so I thought I'd try once more.
Thanks for responding and explaining.  I hadn't noticed the Item.Style properties.

1) I see once I change the rendering from RichText to Gdi and set the FontStyle property I can get the same results as a Label control.

2) When using GdiPlus or Gdi I do now see the mnemonic underlined when using the ampersand character.  However, when I press Alt + <mnemonic> I hear a beep and focus is not being moved to the next field in the tab order.  Is this a bug?

3) In the "Extended Entry Controls" C# example that comes with the Nevron toolkit it shows a form using the NEntryContainer with a prompt which has a label and a red asterisk together.  Thus its using the RichText rendering.  I was inspired by this but I was looking forward to having mnemonic support too.  I've not tried this but I suppose I can use the underline rich text tag and then override the control and add the processmnemonic method to get mnemonic support on a rich text rendering but does the control provide any easier support than this?
By Nevron Support - 9 Years Ago
Hello Craig,

You can display underline using RichText mode too. All you need to do is to surround the desired text or character with <u> tag (<u><\u> ).
However, the NRichTextLabel does not support real mnemonic functionality as it is in the standard Label control.