Re: RichEdit Attributes Bold, Italic, Underline
- Posted by Craig Welch <euphoria at cwelch.org> Apr 18, 2006
- 467 views
Alan Hollingsworth wrote: > Instead of using the font dialog to change attributes like bold, italic, > underline > I want to use a seperate button for each and toggle these attributes on/off > for > either selected text or from the insertion point while editing text. > > Nothing I try seems to work. Is there a way of doing this, Or am I better off > just using the font dialog instead? My understanding is that you would have to (with code in your button) do the following. Get the selected text with buffer = getStream(RichTextField, StreamRTF). Modify it to change various attributes (see below). Put the text back in the control with putstream(RichTextField, StreamRTF, buffer). To change the attributes of the text, you would have to learn up on RTF. As an example, the following will display the word 'Euphoria' in plain text then in bold text on a new line: ===================================== {\rtf1\ansi\deff0 {\fonttbl{\f0 Times New Roman;} } \f0 Euphoria\par \b \f0 Euphoria } ===================================== The only change is the '\b' to make it bold, but it's the placement that is the key. To test it, copy the file to a text editor; save it with a filetype of .rtf; double-click, and it should open in Word. -- Craig