Text formatting

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Text formatting

Post by bsouthuk » Thu Mar 09, 2017 11:23 am

Hi Livecode!

We are looking to enhance the experience of our Livecode desktop Proposal Management system application for users when they need to edit text in a field. i.e change colour of text, make bold, increase text size, bullet points etc etc. I understand this can be coded but I don't want to reinvent the wheel if there is a solution already out there.

Could anyone point me in the right direction or if they know any 3rd party add-on?

Many thanks

Daniel

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Text formatting

Post by FourthWorld » Thu Mar 09, 2017 7:53 pm

I keep threatening to make a nice drop-in text style toolbar, but alas other work keeps getting in the way.

No worries, though - not hard to roll your own.

In the Dictionary see the textStyle property. Esp. useful for menu items is the array form, which allows you to toggle specific style attributes without affecting others, e.g.:

Code: Select all

on menuPick pItem
  switch pItem
    case "bold"
    case "italic"
    case "underline"
       set the textStyle[pItem] of the selection to (not the textStyle[pItem] of the selection)
       break
    case "My Custom Style"
      -- put any custom handling beyond the built in styles here
     break
  end switch
end menuPick
Note that this example is off-the-cuff and untested. If you find anything amiss working with it as a starting point post back here and we'll help sort it out.

Bonus points: we're still in the process of updating the text handling portion of the User Guide (big job; the field object is awesomely rich), but you may find the notes here in the section "New Field Features" beginning on p12 very helpful - wonderful additions for paragraph-level fotmatting, so many you'll probably never use them all but good to learn about them in case you ever do:

http://downloads.livecode.com/livecode/ ... -5_5_4.pdf
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Talking LiveCode”