Page 1 of 1

Change style of a selection of a native iOS text ?

Posted: Sun Apr 15, 2012 7:30 am
by ludo
Hello,

I don't found how change only the selection of an native text ?

Any ideas ? Thanks.

Re: Change style of a selection of a native text ?

Posted: Sun Apr 15, 2012 11:36 am
by bn
Hi Ludo,

look at selectedChunk and textStyle in the dictionary.

make a button and a field

put

Code: Select all

on mouseUp
   put the selectedChunk into tChunk
   set the textStyle of tChunk to bold
end mouseUp
into the script of the button.

Select some text in the field and hit the button.

Kind regards

Bernd

Re: Change style of a selection of a native text ?

Posted: Tue Apr 17, 2012 6:24 am
by ludo
Thanks,

That's the script i use for a "size" button :

Code: Select all

 
      set the textsize of the selected chunk to (the textsize of the selected chunk)+1
      
but this doesn't work when i use a native iOS text with iphoneControlSet. I can't get the selectedchunck and :

Code: Select all

iphoneControlSet "text", "fontsize", "32"
-- change all the text on the field
i found a "selectedRange" option in the documentation but i don't know how use it.

Re: Change style of a selection of a native iOS text ?

Posted: Tue Apr 17, 2012 8:39 am
by jmburnod
Hi Ludo,

no space between "selected" and "chunk"

Best regards

Jean-Marc

Re: Change style of a selection of a native iOS text ?

Posted: Tue Apr 17, 2012 10:47 am
by ludo
jmburnod wrote:Hi Ludo,

no space between "selected" and "chunk"
Yes, it's just the Lion's autocorrection which has corrected my script ! But my real script is ok. It work with a live code field but not with an "iOS field" (created by iphoneControlSet)

Re: Change style of a selection of a native iOS text ?

Posted: Tue Apr 17, 2012 11:22 am
by bn
Hi Ludo,
i found a "selectedRange" option in the documentation but i don't know how use it.
I made a little stack that lets you select parts of the text of a native iOS field.

HOWEVER, I did not find a way to change just the selected part of the text. All changes to fontSize etc change the whole text.
StackSelectedRange.livecode.zip
(2.26 KiB) Downloaded 267 times
Kind regards

Bernd