Hi Guys,
Im working on my data entry screen. I want to have four buttons to style my text, plain, bold, italics and underline. Each of the buttons has the following stype of code on the mouseup handler.
set the textStyle of the selectedChunk to "bold"
So when I highlight my text, and apply the bold button, the text as expected goes bold. Similarly when I select Italics, the highlighted text turns into italics.
What I want to also to do is if the selected text already has a style attached to it, I want to add another style to it. I've checked dictionary it looks like you can add a styleslist. The only thing is I don't know what delimiter I need to use for the styles list. I've got the following code below on my mouse up handler for the bold button. Can someone point me in the right direction please.
put the textStyle of the selectedChunk into tStyle
set the textStyle of the selectedChunk to "bold " & tStyle
Adding multiple textstyle
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Adding multiple textstyle
For the last several versions, text styles can also be set using array notation to toggle each individually:
Code: Select all
set the textStyle["bold"] of word 1 of fld 1 to true
set the textStyle["italic"] of line 2 of fld 1 to false
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Adding multiple textstyle
Hi.
You can also do this in the clear:
set the textstyle of yourChunk to "italic,bold,box"
But I think what you want to do is to build compound textstyles onto chunks that may already have one. That is, if the third word is already "italic", and you press the "bold" button, the textstyle does not simply change to" bold", but rather to "italic,bold".
Is this so? If it is, you seem more than capable fo implementing it. You do not even need a custom property to hold the "history" of the existing style suite, since the "textStyle" property already does all that. Get going. Or ignore me if I am off base here.
EDIT: You already nearly did this above, I now see. You neglected to insert a comma, though. The syntax for a styleList is "style1,stlye2,style3,etc."
Craig Newman
You can also do this in the clear:
set the textstyle of yourChunk to "italic,bold,box"
But I think what you want to do is to build compound textstyles onto chunks that may already have one. That is, if the third word is already "italic", and you press the "bold" button, the textstyle does not simply change to" bold", but rather to "italic,bold".
Is this so? If it is, you seem more than capable fo implementing it. You do not even need a custom property to hold the "history" of the existing style suite, since the "textStyle" property already does all that. Get going. Or ignore me if I am off base here.
EDIT: You already nearly did this above, I now see. You neglected to insert a comma, though. The syntax for a styleList is "style1,stlye2,style3,etc."
Craig Newman
Re: Adding multiple textstyle
Hi Both,
Thanks Craig, that was exactly what I was looking for. I used the pipe delimiter and the space as a delimiter but should have used the comma!
All the best
Jalz
Thanks Craig, that was exactly what I was looking for. I used the pipe delimiter and the space as a delimiter but should have used the comma!
All the best
Jalz
Re: Adding multiple textstyle
The dictionary does actually not leave any doubt about this!I used the pipe delimiter and the space as a delimiter but should have used the comma!
