Page 1 of 1
Text formatting
Posted: Wed Aug 12, 2009 5:34 pm
by Philhold
Hi,
I'm trying to make a simple application that needs to apply basic text formatting to chunks within text in a field. I want to be able to select a word and then click a button to make that text go bold for example.
The button that has a script like this.
Code: Select all
on mouseDown pMouseBtnNo
set the textStyle the selectedChunk of field "mText" to "bold"
end mouseDown
It doesn't work but I'm at a loss to see why.
Any pointers would be much appreciated.
Thanks
Phil
PS If you recognise the name it is because I got started with RR some time ago and then my priorities got changed for me. I'm back again having slid down the snake to square one.
Posted: Wed Aug 12, 2009 5:56 pm
by Klaus
Hi Phil,
did you check "the selectedchunk" in the Rev Dictionary?
Obviously not, but that is ALWAYS a good idea
"the selectedchunk" MUST not have a descriptor (...of whatever) like in your script, since it returns something like "char x to y OF FIELD Z".
So just write:
...
set the textStyle the selectedChunk to "bold"
...
and you are done
Best
Klaus
P.S.
Most of the beginners questions here in the forum would be answered by a quick look into the docs...
Posted: Wed Aug 12, 2009 9:28 pm
by Philhold
Thanks Klaus,
In fact your line throws an error should be:
Code: Select all
set the textstyle of selectedchunk to "bold"
I always search the docs first but you have to know what you are looking for. Then as a last resort ask here.
Cheers
Phil
Posted: Thu Aug 13, 2009 8:38 am
by Klaus
Hi Phil,
sorry, but MY line does not throw an error, YOUR line does
Add THE -> "of THE selectedchunk" and you're done!
Best
Klaus
Posted: Thu Aug 13, 2009 8:59 am
by Philhold
Hi Klaus,
set the textStyle of selectedChunk to "bold"
definitely works here but what you said
So just write:
...
set the textStyle the selectedChunk to "bold"
...
and you are done Smile
throws an error. textStyle
of the selectedChunk works as well. I only mentioned it as this forum is for newbies and these tiny specifics of grammar are often what catches us out. I didn't mean to sound ungrateful as I am very grateful for your advice.
Many thanks
Phil
Posted: Thu Aug 13, 2009 10:03 am
by Klaus
Hi Phil,
oh damn, you are right, of course, my fault, please excuse me!
Will be more careful in the future.
Best
Klaus
P.S.
But at least I did not forget the "THE"
But:
set the textStyle of selectedChunk to "bold"
threw an error here...?!
Posted: Thu Aug 13, 2009 10:45 am
by Philhold
Hi Klaus,
Are you using a different version to me? I'm running 3.5.0-gm-1 and it does not seem to need "the".
I'm really struggling to get simple text format toggling to work and may just throw in the towel and use rrpHTMLToolbar.
How hard can it be to check the current status of the selectedchunk and then if it is say bold make it normal or the other way around? Also the lack of built in toggle buttons doesn't help.
Cheers
Phil
Posted: Thu Aug 13, 2009 11:10 am
by Klaus
Hi Phil,
well, I am using just another IDE: MetaCard, but the underlying engine is the SAME,
so differences should not appear at all?!?
Anyway, in my current project I have a text format palette and use checkboxes (with custom icons!)
to represent the state of "bold" and/or "italic" and manage this with something like this:
Code: Select all
on selectionchanged
put the effective textfont of the selectedchunk into tCh
set the hiltite of btn "bold" to tCh caontains "bold"
set the hilite of btn "italic" to tCh contains "italic"
end selectionchanged
You get the picture
Best
Klaus
Posted: Thu Aug 13, 2009 11:16 am
by Philhold
Hi Klaus,
Many thanks for that. Also for anyone else having problems with this Sarah's blog here
http://sarahrev.blogspot.com/ is interesting.
Thanks again
Phil