ttown253
10 years agoVisitor
Text Wrapping in roImageCanvas
Hi all,
I'm using an roImageCanvas to build a grid of rectangles that will make a grid for TV listings.
Basically how I understand it is, you position your text on the screen via a TargetRect with an X, Y position and a length and width.
The width of the TargetRect handles the wrapping great. If the text is too wide for the TargetRect, it wraps to the next line.
What I'm trying to figure out is how to get it to stop displaying text if there are too many lines. It's not doing anything about the height of the TargetRect. It will just keep printing the text, albeit the correct width, on several lines well beneath the TargetRect.
Is there any way to solve this issue without complex coding, text width analysis, etc?
Here's my code which put's a red rectangle on the screen the same size as the Text's TargetRect. The text printed goes outside of the bottom of the TargetRect because it's too long.
I'm using an roImageCanvas to build a grid of rectangles that will make a grid for TV listings.
Basically how I understand it is, you position your text on the screen via a TargetRect with an X, Y position and a length and width.
The width of the TargetRect handles the wrapping great. If the text is too wide for the TargetRect, it wraps to the next line.
What I'm trying to figure out is how to get it to stop displaying text if there are too many lines. It's not doing anything about the height of the TargetRect. It will just keep printing the text, albeit the correct width, on several lines well beneath the TargetRect.
Is there any way to solve this issue without complex coding, text width analysis, etc?
Here's my code which put's a red rectangle on the screen the same size as the Text's TargetRect. The text printed goes outside of the bottom of the TargetRect because it's too long.
function Main()
canvas = CreateObject("roImageCanvas")
canvas.SetLayer(0, [
{
Color: "#FF0000",
TargetRect: {x: 400, y: 300, h: 100, w: 400}
},
{
Text: "Hello this is a long sentence about something I will see on TV someday and this is a continuation of that sentence which will wrap beneath the target rectangle",
TextAttrs: {color: "#FFFFFF", valign: "Top", halign: "Left"},
TargetRect: {x: 400, y: 300, h: 100, w: 400}
}
])
port = CreateObject("roMessagePort")
canvas.SetMessagePort(port)
canvas.Show()
while true
event = Wait(0, port)
if (event.IsRemoteKeyPressed())
index = event.GetIndex()
if (index = 6) ' Press OK to exit
exit while
end if
end if
end while
end function