The ScreenOrientation Module is used to control the screen orientation / layout and register to receive an event when it changes.
In order to use this API you must include the following extension in your build.yml
.
:::ruby
extensions: [“screenorientation”]
Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript.
Be sure to review the Ruby API Usage guide for important information about using this API in Ruby.
With the old PocketBrowser / RhoElements 1 APIs, any events, such as screenOrientationEvent
were canceled when a full navigate was performed. The original reason for this was a limitation of the IE engine on WM5 devices. When moving to the common API this was changed so that callbacks are not canceled.
Sets the screen orientation to left-handed orientation. Note the webpage will not reformat in line with the new screen size automatically.
Synchronous Return:
Method Access:
Rho.ScreenOrientation.leftHanded()
Rho::ScreenOrientation.leftHanded()
Sets the screen orientation to default device orientation.
Synchronous Return:
Method Access:
Rho.ScreenOrientation.normal()
Rho::ScreenOrientation.normal()
Sets the screen orientation to right-handed orientation. Note the webpage will not reformat in line with the new screen size automatically.
Synchronous Return:
Method Access:
Rho.ScreenOrientation.rightHanded()
Rho::ScreenOrientation.rightHanded()
Sets the callback to be called when a screen orientation event occurs.
Parameters
Async Callback Returning Parameters: STRING
Synchronous Return:
Method Access:
Rho.ScreenOrientation.setScreenOrientationEvent(CallBackHandler callback)
Rho::ScreenOrientation.setScreenOrientationEvent(CallBackHandler callback)
Sets the screen orientation to upside down, useful if presenting the device to a customer to obtain a signature.
Synchronous Return:
Method Access:
Rho.ScreenOrientation.upsideDown()
Rho::ScreenOrientation.upsideDown()
Enables or Disables auto-rotation of the screen orientation when the device is rotated. For Windows Mobile/CE devices, support is limited to only Symbol Technologies devices with IST Sensor support.
Default: true
Property Access:
myObject.autoRotate
Detect when the device changes orientation.
function start_detecting_orientation_changes(){ ScreenOrientation.setScreenOrientationEvent(orientation_callback) } function orientation_callback(){ Alert.show_popup("The screen changed orientation") }
def start_detecting_orientation_changes Rho::ScreenOrientation.setScreenOrientationEvent(url_for(:action => :orientation_callback)) end def orientation_callback Alert.show_popup("The screen changed orientation") end
Set the screen orientation programmatically. Particularly useful in a tablet: before capturing a signature, set the orientation to upside-down so that the interface will look right from the signer’s point of view without having to physically rotate the device.
function capture_signature_with_attention_to_details() { // Set screen orientation to upside down Rho.ScreenOrientation.upsideDown(); // At this point, offer the device to the user. You just saved the user the hassle of rotating the tablet // and there's less potential for the device to be dropped along the way Rho.Signature.takeFullScreen({}, signature_callback); } function signature_callback(params) { // do whatever we need to do with the signature ... // restore screen orientation to default Rho.ScreenOrientation.normal(); }
def capture_signature_with_attention_to_details # Set screen orientation to upside down Rho::ScreenOrientation.upsideDown # At this point, offer the device to the user. You just saved the user the hassle of rotating the tablet # and there's less potential for the device to be dropped along the way Rho::Signature.takeFullScreen({}, url_for(:action => :signature_callback)) end def signature_callback # do whatever we need to do with the signature ... # restore screen orientation to default Rho::ScreenOrientation.normal end
Enable / disable automatic rotation of the screen according to device orientation.
// Enable autorotate Rho.ScreenOrientation.autoRotate=true; // Disable autorotate Rho.ScreenOrientation.autoRotate=false;
# Enable autorotate Rho::ScreenOrientation.autoRotate=true # Disable autorotate Rho::ScreenOrientation.autoRotate=false