getSize
Retrieves the width and height of the specified panel object, in pixels.
Syntax
ogscript.getSize (ID);
Parameters
Parameter |
Type |
Required |
Description |
ID |
String |
Yes |
ID of the panel object. |
Returns
Dimension object with d.width and d.height available.
Example
The following example draws a label that can be resized and repositioned. When the user drags the middle of the label, it moves. When the user drags the bottom right corner of the label, the label is resized.
<absbottom="0" contexttype="opengear" left="0" right="0" top="0">
<meta>
<ogscript handles="onmousedown" targetid="move-label">var size = ogscript.getSize('move-label');
if (event.getX() < size.width - 10 && event.y < size.height - 10)
{
ogscript.putObject('mode', 'move'); ogscript.putObject('position', ogscript.getPosition('move-label')); ogscript.putObject('offsetX', event.x); ogscript.putObject('offsetY', event.y);
}
else
{
ogscript.putObject('mode', 'size');
}
</ogscript>
<ogscript handles="ondrag" targetid="move-label">
if (ogscript.getObject('mode') == 'size')
{
ogscript.setSize('move-label', event.getX(), event.getY());
}
else if (ogscript.getObject('mode') == 'move')
{
var origin= ogscript.getObject('position'); var offsetX= ogscript.getObject('offsetX'); var offsetY= ogscript.getObject('offsetY');
ogscript.reposition('move-label', origin.x+ event.x - offsetX, origin.y + event.y - offsetY);
ogscript.putObject('position', ogscript.getPosition('move-label'));
}
</ogscript>
</meta>
<label height="116" id="move-label" left="27" style="bdr:etched;bg#FF0000" top="38" width="215"/>
</abs>