Page 1 of 1
When "red" isn't red
Posted: Wed Jan 20, 2016 10:08 pm
by RossG
I've set the backgroundColor of many fields without any problems but
I have one which refuses to change color.
What's even stranger is that putting the backgroundColor in the message
window gives "red" while the backgroundColor displayed definitely isn't.
What gives?
Re: When "red" isn't red
Posted: Wed Jan 20, 2016 10:54 pm
by bn
Hi Ross,
is "opaque" set for that field? Check in the Properties Inspector. If not it would be transparent. That could explain it.
Kind regards
Bernd
Re: When "red" isn't red
Posted: Thu Jan 21, 2016 1:53 am
by RossG
Thanks bn - that did it.
An unrelated question. I want a column of AveDev numbers to
be aligned but some have one decimal place and others have none.
I think there's a way to "pad" or "fill" but can't find any reference to
such.
Problem half solved - found numberFormat but using "#.0" means
that 8.1 doesn't line up with 10.1 and using "##.0" makes 8.1 into
08.1.
Help appreciated.
Re: When "red" isn't red
Posted: Thu Jan 21, 2016 2:23 am
by dunbarx
Hi.
Not sure I understand. Do you want decimal point align?
Craig Newman
Re: When "red" isn't red
Posted: Thu Jan 21, 2016 10:06 am
by bn
Hi Ross,
Livecode can not do decimal align, but as of 7 and up it can do right align for tabular data (data tab data tab data return and so on)
try this with a button and a field and change to what you need. If you want columnar data it is a bit more involved. You would place your data tab delimited for columns and return delimited for rows into the field.
But for just 1 column this should work.
Code: Select all
on mouseUp
-- set up formatting
set the numberformat to "#.00"
set the tabStops of field 1 to 70 -- change position here
set the tabAlign of field 1 to "right"
-- fill with random numbers
repeat 10
put random (12) - 1 + random(3) / 3 / 10 & cr after tCollect
end repeat
put tCollect into field 1
end mouseUp
I will be offline the next couple of days, but maybe this gets you started
Kind regards
Bernd
Re: When "red" isn't red
Posted: Thu Jan 21, 2016 12:40 pm
by Lagi Pittas
Hi,
I had the same problem - so I rolled my own to have more control
Code: Select all
Function Currency pnValue, pnDigits, pnDecimals
Local lcFormat, lnReturnVal
-- Fixes the problem that when subtractions to zero
-- gives -0.0 in livecode, this makes it really zero
if pnValue is zero then
put 0 into pnValue
end if
If (pnDigits Is Empty) Then
Put 7 Into pnDigits
End If
If (pnDecimals Is Empty) Then
Put 2 Into pnDecimals
End If
Put "%" & pnDigits & "." & pnDecimals & "f" Into lcFormat
put Format(lcFormat, pnValue) into lnReturnVal
return (lnReturnVal)
End Currency
The above function assumes a width of 7 (padded left with spaces) and 2 decimal places so if you pass 0 you will get back
^^^0.00
if you call it with Currency(1.2,5,3) you will get back
^1.23
where the caret signs (^) mean space of course
Hope this helps
Re: When "red" isn't red
Posted: Sun May 15, 2016 1:24 am
by RossG
The problem with the backgoundColor not appearing
correctly was, I think, related to my other problem with
fields after copying.