I’m working on an app that has a simple title at 0,0, and then a Group set at 0,Text.LINE_HEIGHT. That group subsequently has a Text item at coordinates 0,0. I expect that Text item’s coordinates to be relative to the Group’s position, which on the screen would be 0,Text.LINE_HEIGHT. However, when testing, I keep finding the Text item to be at 0,0 on the screen. Here’s some sample code:
var app = require('app');
app.init();
var screen = require('screen');
window.clear();
print("window w, h = " + window.w + ", " + window.h + "\n");
var alertGroup = new Group(0, Text.LINE_HEIGHT,
window.w, window.h - Text.LINE_HEIGHT);
var alertText = new Text(0, 0, window.w, Text.LINE_HEIGHT);
alertText.align(Widget.TOP | Widget.LEFT | Widget.WRAP);
alertGroup.add(alertText);
window.onkeycancel = digium.background;
window.add(screen.setTitleText({ 'title' : 'Tiny Title' }));
window.setSoftkeysByList([
{
'label' : '',
'handler' : ''
},
{
'label' : '',
'handler' : ''
},
{
'label' : '',
'handler' : ''
},
{
'label' : 'Close',
'handler' : digium.background,
'icon' : app.images.softKeys.cancel
}
]);
window.add(alertGroup);
alertText.label = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.";
alertText.fitLabel();
What I end up getting is what is showing in the attached screen shot. I know I’m missing something simple, but I sure can’t see it…