Change style of a selection of a native iOS text ?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ludo
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 72
Joined: Mon Dec 03, 2007 6:10 pm

Change style of a selection of a native iOS text ?

Post by ludo » Sun Apr 15, 2012 7:30 am

Hello,

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

Any ideas ? Thanks.
Last edited by ludo on Tue Apr 17, 2012 6:34 am, edited 1 time in total.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4177
Joined: Sun Jan 07, 2007 9:12 pm

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

Post by bn » Sun Apr 15, 2012 11:36 am

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

ludo
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 72
Joined: Mon Dec 03, 2007 6:10 pm

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

Post by ludo » Tue Apr 17, 2012 6:24 am

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

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

Post by jmburnod » Tue Apr 17, 2012 8:39 am

Hi Ludo,

no space between "selected" and "chunk"

Best regards

Jean-Marc
https://alternatic.ch

ludo
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 72
Joined: Mon Dec 03, 2007 6:10 pm

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

Post by ludo » Tue Apr 17, 2012 10:47 am

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)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4177
Joined: Sun Jan 07, 2007 9:12 pm

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

Post by bn » Tue Apr 17, 2012 11:22 am

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 266 times
Kind regards

Bernd

Post Reply