When "red" isn't red
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
When "red" isn't red
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?
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?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: When "red" isn't red
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
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
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.
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.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: When "red" isn't red
Hi.
Not sure I understand. Do you want decimal point align?
Craig Newman
Not sure I understand. Do you want decimal point align?
Craig Newman
Re: When "red" isn't red
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.
I will be offline the next couple of days, but maybe this gets you started
Kind regards
Bernd
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
Kind regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 366
- Joined: Mon Jun 10, 2013 1:32 pm
Re: When "red" isn't red
Hi,
I had the same problem - so I rolled my own to have more control
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
Hope this helps
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
if you call it with Currency(1.2,5,3) you will get back^^^0.00
where the caret signs (^) mean space of course^1.23
Hope this helps
Re: When "red" isn't red
The problem with the backgoundColor not appearing
correctly was, I think, related to my other problem with
fields after copying.
correctly was, I think, related to my other problem with
fields after copying.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.