This content has been marked as final. Show 6 replies
when you get a selection you need to apply the formatting directly to the member... setting the text chunk to a variable creates a separate string in memory that does not reference the member's text anymore... so do this instead:
vMem = member("annotator")
vSelect = vMem.selection
if not(vSelect = vSelect) then
vMem.char[vSelect + 1..vSelect].fontstyle = [#bold] -- use "bold" if it's a field member.
** Note: if you do want to set a variable then you can create a direct reference in memory using the undocumented .ref property, ie.
textRef = vMem.char[vSelect + 1..vSelect].ref
textRef.fontstyle = [#bold]
-- this is useful when wanting to set several properties of a text chunk at one time.
put textInsert after member( "annotator" ).char[( member( "annotator" ).selection )]
Thank you both for your reply... My second question has been answered. As for the first I have something more that I would like some help. I wonder how can i change the color of the text in the textInsert variable and insert it with the specific color (e.g., red) in the member annotator.
Many thanks for your help
vMem = member( "annotator" )
vInsertPos = ( vMem.selection )
put textInsert after vMem.char[vInsertPos]
vMem.char[vInsertPos + 1..vInsertPos + textInsert.length].color = rgb( 255, 0, 0 )
Thank you so much... just one more thing... although the text of the textInsert variable becomes red the problem is that if i will type a word after that text it is also red. Is there any way to make only the textInsert red and keep the rest of the text in the field black?
OK, I found a workaround to the above question by creating a menu items that will colorize the wanted text back to black. So topic closed many thanks for your help