Orientation: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
 
(12 intermediate revisions by the same user not shown)
Line 4: Line 4:


The Orientation control puts up a full screen message if the orientation changes. If your app is only designed to run in Portrait mode and the user rotates to Landscape, it will black out the screen and ask the user to rotate back. The previous content of the screen will display once this happens. It can also be set to make Landscape the allowed orientation.
The Orientation control puts up a full screen message if the orientation changes. If your app is only designed to run in Portrait mode and the user rotates to Landscape, it will black out the screen and ask the user to rotate back. The previous content of the screen will display once this happens. It can also be set to make Landscape the allowed orientation.
To use it, select it from the controls in the Toolbox so it gets added to the Project Explorer. It will not show on the Design Screen. To remove it, highlight it in the Project Explorer and delete.
Once added to any form, it will apply to the entire project.


== Properties and Methods ==
== Properties and Methods ==


Standard [[properties and methods|properties]] are supported, plus:
The Orientation control has the following properties:
{| class="wikitable"
{| class="wikitable"
|-
| messageLandscape || Text displayed when rotated.
|-
| messagePortrait || Text displayed when rotated.
|-
|-
| screenOrientation || Normal orientation: Portrait or Landscape. Design time only.
| screenOrientation || Normal orientation: Portrait or Landscape. Design time only.
Line 14: Line 22:


== Example ==
== Example ==
While no code is needed to use this control, here are a some useful functions for dealing with orientation.
To get the current orientation:


<pre>
<pre>
'This sample shows how to use the NSB.ShowProgress function
MsgBox "window.orientation = " & window.orientation
'Set a global counter and call updateMessage every quarter second
Dim count=0
SetInterval(updateMessage,250)
Sub updateMessage()
  count=count+1
  If count<20 Then
    'Display the progress message followed by dots
    NSB.ShowProgress("Loading" & String(count,"."))
  Else
    'Clear the progress message and stop calling updateMessage
    NSB.ShowProgress()
    ClearInterval(updateMessage)
  End If
End Sub
Sub custDone(result)
  Text2.value=result
End Sub
</pre>
</pre>


== Output ==
To execute code when the orientation changes:


<pre>
<pre>
(depends on use. See nsbShowProgress sample)
Function window_onorientationchange()
  'This function is called if the orientation of the device is changed.
  MsgBox "orientation changed to " & window.orientation
End Function
</pre>
</pre>
== Output ==
If the ''screenOrientation'' is "portrait", the message above will be displayed when the screen is rotated.


== Related Items ==
== Related Items ==
[[msgbox|MsgBox]]


[[Category:Language Reference]]
[[Category:Language Reference]]


[[Category:Messages]]
[[Category:Messages]]
[[Category:Common]]

Latest revision as of 22:15, 9 March 2019

Description

The Orientation control puts up a full screen message if the orientation changes. If your app is only designed to run in Portrait mode and the user rotates to Landscape, it will black out the screen and ask the user to rotate back. The previous content of the screen will display once this happens. It can also be set to make Landscape the allowed orientation.

To use it, select it from the controls in the Toolbox so it gets added to the Project Explorer. It will not show on the Design Screen. To remove it, highlight it in the Project Explorer and delete.

Once added to any form, it will apply to the entire project.

Properties and Methods

The Orientation control has the following properties:

messageLandscape Text displayed when rotated.
messagePortrait Text displayed when rotated.
screenOrientation Normal orientation: Portrait or Landscape. Design time only.

Example

While no code is needed to use this control, here are a some useful functions for dealing with orientation.

To get the current orientation:

MsgBox "window.orientation = " & window.orientation

To execute code when the orientation changes:

Function window_onorientationchange()
  'This function is called if the orientation of the device is changed.
  MsgBox "orientation changed to " & window.orientation
End Function

Output

If the screenOrientation is "portrait", the message above will be displayed when the screen is rotated.

Related Items