selectedText textFont not working?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

selectedText textFont not working?

Post by hamlynart » Mon Sep 08, 2008 12:37 pm

Hi Folks,

I can't work out what I'm doing wrong here.

set the textFont of the selectedChunk of fld "myField" to "Arial"

I have a font menu and when the user selects some text in field "myField" I want them to be able to change the font.

What am I doing wrong?

Thanks

Jim

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon Sep 08, 2008 12:51 pm

Try this:

Code: Select all

on menuPick pFontName
  if the focusedObject is the long ID of field "MyField" then
    set the textFont of the selection to pFontName
  end if
end menuPick
The 'selectedChunk' property can be a little annoying to work with, as the engine may attempt to 'interpret' it before using it - and then it thinks it has ended up with the following instruction:

Code: Select all

set the textFont of "whatever the selected text is" to "Arial"
Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Post by hamlynart » Mon Sep 08, 2008 12:57 pm

Blimey, it works perfectly!

Thanks so much.

Jim

Post Reply