copy format of text to datagrid

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
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

copy format of text to datagrid

Post by jalz » Fri Apr 28, 2017 10:48 pm

Hi Guys,

I have a field I type text into. I can style, change text size and align it in the standard ways. Once I stop editing the field I press a button which then copies the text from that particular field into the equivalent field in my datagrid (form). The issue I have is when I copy the text from that field to the datagrid I lose all the formatting, thought the only way to do this was using htmltext as the option.

I use the following code,

the button I press to copy the text

Code: Select all

on mouseup
set the text of field "fld_line_description" of me to pDataArray["label 3"]
dispatch "AddData" to group "dg_data" with theDataA, tLineNo
end mouseup

datagrid form code which fills the field

Code: Select all

on FillInData pDataArray
set the htmltext of field "fld_line_description" of me to pDataArray["label 3"]
end FillInData

Last edited by jalz on Fri Apr 28, 2017 11:35 pm, edited 1 time in total.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: copy format of text to datagrid

Post by Klaus » Fri Apr 28, 2017 11:27 pm

Hi Jalz,
jalz wrote:...
the button I press to copy the text

Code: Select all

on mouseup
  set the text of field "fld_line_description" of me to pDataArray["label 3"]
  dispatch "AddData" to group "dg_data" with theDataA, tLineNo
end mouseup
not sure I get it, but this script does not copy anything!?

Maybe you mean:

Code: Select all

on mouseup
  put the htmltext of field "fld_line_description" of me into pDataArray["label 3"]
  dispatch "AddData" to group "dg_data" with theDataA, tLineNo
end mouseup
?

And is tLineNo declared as local or globa?


Best

Klaus

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: copy format of text to datagrid

Post by jalz » Fri Apr 28, 2017 11:53 pm

Hi Klaus

Thanks for replying. Trying to get my head stuck back into LIvecode :).

Yes you are absolutely right, it is htmltext I am using when I am storing it in a variable.

The datagrid fills in the data using the FillInData command.

set the text of field "fld_line_description" of me to pDataArray["label 3"]

I've been playing with the code, I've now got the datagrid field to display html tags (which includes the formatting). How do I get the field to display in 'normal' text?

Thanks
Jalz

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: copy format of text to datagrid

Post by Klaus » Sat Apr 29, 2017 12:04 pm

Hi jalz,
jalz wrote:I've been playing with the code, I've now got the datagrid field to display html tags (which includes the formatting). How do I get the field to display in 'normal' text?
in that case just copy the text of your field:

Code: Select all

...
put the text of field "fld_line_description" of me into pDataArray["label 3"]
...
If you need an "ad hoc" conversion from HTMLTEXT to "normal" text I would use a little function like this:

Code: Select all

...
set the text of field "fld_line_description" of me to htmltext2text (pDataArray["label 3"])
...

function htmltext2text tHTMLTEXT
   set the htmltext of the templatefield to tHTMLTEXT
   put the text of the templatefield into tText
   reset the templatefield
   return tText
end htmltext2text
Tested and works! :D

Best

Klaus

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: copy format of text to datagrid

Post by jalz » Sat Apr 29, 2017 7:03 pm

Thanks Klaus

That worked :D

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: copy format of text to datagrid

Post by Klaus » Mon May 01, 2017 4:59 pm

jalz wrote:Thanks Klaus

That worked :D
Did you really doubt? 8)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”