word wrap with tabbed field

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
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

word wrap with tabbed field

Post by Da_Elf » Sat Jul 09, 2016 6:48 pm

im using a tabbed field to have two items side by side. an item and a price. It was working well until i had an incident where the 1st tabbed part was too long so obviously the 2nd tabbed area is pushed across. is there any way to make the 1st part word wrap inside its area?

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: word wrap with tabbed field

Post by [-hh] » Sat Jul 09, 2016 8:42 pm

For wrapping you could use a dataGrid.

Staying with a simple field you could simply HIDE the overlong part of tab-item 1:

Code: Select all

set tabStops of fld 1 to "70,42"
set vgrid of fld 1 to true
Of course you can also measure each first tab-item with formattedWidth and set item 1 of the tabStops to the max.
And

Code: Select all

set vgrid of fld 1 to false
shows again the item with its full length.
The color of the grid is set by the borderColor of the field.
shiftLock happens

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: word wrap with tabbed field

Post by Da_Elf » Sat Jul 09, 2016 9:31 pm

for some reason i hate data grid and have mind blocked myself from learning it grrr. also what im doing is printing a recipt. so when the receipt is being created it lists all items tabbed with its cost next to it. if the item is too long in name the price is forced off the side of the receipt.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: word wrap with tabbed field

Post by [-hh] » Sat Jul 09, 2016 9:52 pm

You could break overlong items by script.
If you put CR & "..." after char x of such an item, say after char 12 if length(item) > 16, this generates a line with an empty price entry before the overlong item.
Disadvantage: Sorting requires more work.
[You could replace CR & "..." with an unusual char for sorting and revert this after sorting.]
shiftLock happens

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: word wrap with tabbed field

Post by Da_Elf » Sat Jul 09, 2016 10:48 pm

hmmm. if i cr the 1st item. then tab the next item (the price)... the price would line up to the 2nd line of the cr. i think you have something there. ill test it tonight and get back to this

AND A BIG SHOUT OUT TO LIVECODE

i have been teaching my 12 year old class programming and we have made a small game in it in our class. (just in case anyone big reads this)

hpsh
Posts: 52
Joined: Tue Aug 25, 2015 8:06 pm

Re: word wrap with tabbed field

Post by hpsh » Sun Jul 10, 2016 3:36 pm

for some reason i hate data grid and have mind blocked myself from learning it grrr. also what im doing is printing a recipt. so when the receipt is being created it lists all items tabbed with its cost next to it. if the item is too long in name the price is forced off the side of the receipt.
has the same problem, i have been able to get it to work, i just don't understand how :-) thinks it partly because the format for headers, are different from the contens :-(

have a little database whit a tabbed field, and a grid, but the code is not really great, its a start for a summer project for me. maybe thats helps

nb, do have one codeline in stack, the rest of code is in the buttons.
Attachments
friendbase01.zip
(6.01 KiB) Downloaded 198 times

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: word wrap with tabbed field

Post by Da_Elf » Mon Jul 11, 2016 8:01 pm

The file you posted was empty. This was my solution to the problem

Code: Select all

function linetoolong theinputline thelinewidth
   create fld "ytesteroni"
   set width of fld "testlength" to thelinewidth
   set the dontWrap of fld "ytesteroni" to true
   put 1 into myyadvan
   put theinputline into th1
   put the number of words of th1 into fullnumber
   put empty into oldline
   repeat for fullnumber times
      set the text of fld "testlength" to oldline
      if the formattedWidth of fld "testlength" >= the width of fld "testlength" then
         put word -1 of oldline into reword
         delete word -1 of oldline
         put cr & reword & space & word myyadvan of th1 & space after oldline
      else
         put word myyadvan of th1 & space after oldline
      end if      
      add 1 to myyadvan
   end repeat
   delete fld "testlength"
   return oldline
end linetoolong

hpsh
Posts: 52
Joined: Tue Aug 25, 2015 8:06 pm

Re: word wrap with tabbed field

Post by hpsh » Mon Jul 11, 2016 8:53 pm

The file you posted was empty. This was my solution to the problem
thats strange, did download it, and it worked here.

but think we are talking about 2 different things? it was more a comment about the datagrid thing :-/

Post Reply