Difference between revisions of "API Panel.Position.Set"

From Flowcode Help
Jump to navigationJump to search
(XML import of updated API docs)
Line 1: Line 1:
 +
 +
 
<sidebar>API contents</sidebar>
 
<sidebar>API contents</sidebar>
 
Sets an objects position based on a component or pre-defined position
 
Sets an objects position based on a component or pre-defined position
Line 19: Line 21:
  
 
==Return value==
 
==Return value==
''This call does not return a value''
+
[[Variable Types|BOOL]]
 +
 
 +
Returns true if the operation is a success, else false
  
  
Line 30: Line 34:
 
==Examples==
 
==Examples==
 
===Calling in a calculation===
 
===Calling in a calculation===
* Add to a calculation icon: <pre class="brush:[cpp]">::Panel.Position.Set(dest, source)</pre>
+
* Declare a variable 'result' of type BOOL
 
+
* Add to a calculation icon: <pre class="brush:[cpp]">result = ::Panel.Position.Set(dest, source)</pre>
===Flowcode example file===
 
Download [[File:SIMAPI_Panel_Position_Set.fcf]] and open it in Flowcode v6. In this example, there are two spheres. The red sphere has dimensions of 24h,24w,24d, the yellow sphere has dimensions of 12h,12w,12d. This is an important consideration when using the Set() function because it effectively clones the dimensions and coordinates of the source component.
 
 
 
What you will see in this demo is the red sphere move to the coordinates of the yellow sphere and also the red sphere will be resized to that of the yellow sphere. As there are now two objects of exact same dimensions and coordinates the red sphere may look like its dissapeared or you may see both spheres exhibiting some colour collision. The LCD will show the coordinates of both spheres.
 
 
 
After two seconds the red sphere will re-appear back in it's original location and to it's original size. Just using the set() function alone would have successfully moved it back to it's original coordinates but it would '''not''' have resized the red sphere back to it's original dimensions.
 
 
 
To return the red sphere back to it's original dimensions, a clever technique can be used by creating a variable of type Handle. Then using the get() api call we pass a copy of the red sphere's original size and coordinates to this variable. Then use set() api call again this time specifying the variable as the source handle. You can see this clearly in the flowcode example.
 
 
 
The screenshots below show the effect and also highlight the code used by the example.
 
  
[[File:SIMAPI_Panel_Position_Set_Pic1.png]][[File:SIMAPI_Panel_Position_Set_Pic2.png]]
+
''<span style="color:red;">No additional examples</span>''
[[File:SIMAPI_Panel_Position_Set_Pic0.png|800px]]
 

Revision as of 09:58, 17 June 2013


<sidebar>API contents</sidebar> Sets an objects position based on a component or pre-defined position

Class hierarchy

Panel

Position
Set

Parameters

HANDLE Dest

The position or component to update

HANDLE Source

The position or component to read from


Return value

BOOL

Returns true if the operation is a success, else false


Detailed description

This copies the entire contents of a position from Source to Dest. Either handle may be a position or component.

The position will be converted from the sources coordinate-space into the destination space when it is assigned. This means one unit in the Source space is equivalent to one unit in the Dest space, regardless of the scale of owning components.


Examples

Calling in a calculation

  • Declare a variable 'result' of type BOOL
  • Add to a calculation icon:
    result = ::Panel.Position.Set(dest, source)

No additional examples