Changes in OS 3.6

From Inspired-Lua Wiki
Jump to navigation Jump to search

In version 3.6 of the Nspire platform, Lua Scripting changes can be found on the API side as well as on the software's SDK side.

For the sake of completeness of this page to most users, changes will be accounted for since OS 3.2 (apilevel 2.0). In fact, it's worth noting that OS 3.6 comes with the changes of OS 3.4 (iPad).

SDK

Compatibility options

Under the "File" menu, a new menu item appeared : "Set minimum API", which brings up a dialog window asking for the minimum API Level you'd want the user to be on in order to run the script. The format is [1-255].[0-255], although as of Dec. 2013, the available ones are : 1.0, 2.0, 2.2, and 2.3. If a user opens a script which needs a higher (newer) version than what his platform can provide, an error message will appear (http://i.imgur.com/N14AQq7.png), asking the user to update.

Images

If not setting a platform.apiLevel < "2.3", images can now be inserted as "Resources" that get embedded into the .tns file directly, instead of long strings stored directly within the script source. Images can be inserted one by one or several at a time using a csv file (see manual). An image cannot exceed 3 MB. Example code to create an image from a resource image : myImage = image.new(_R.IMG.img_1)

API

Images

  • If not setting a platform.apiLevel < "2.3", image.new now takes a "TI.ResourceHandle" as its first argument (image) instead of a string (TI.Image format). Such a type gets created through the SDK when adding an image resource (see above).

Platform

  • New : platform.apiLevel by default : "2.3"
  • New : platform.isTabletModeRendering -- self explanatory : returns true if the script is running on a tablet device, false otherwise.
  • New : Widget / platform.window : getScrollHeight and setScrollHeight, which respectively return and set the height of the available window size when the tablet's on-screen keyboard is shown.

Touch

  • a new "library" (table), touch :

It is visible on all platforms but may ignore calls to its functions if the platform running the script does not support touch. The touch library offers a low level interface enabling script authors to develop scripts running on all platforms equally. But it also places the effort on the script writer to design and test the script for all different platforms if platform compatibility is desired.

The touch table contains :

enabled : Returns true if the platform supports touch, otherwise false. If touch is supported, it is recommended to use the ppi values to calculate touch target sizes.
isKeyboardVisible() : Returns true if any keyboard is visible (docked, oating and split keyboards).
isKeyboardAvailable : Returns true if an on-screen keyboard is available on the platform, otherwise false.
showKeyboard(boolean) : Causes the docked ABC keyboard to appear on the screen if no keyboard is currently visible. Default is true.
ppi : Returns pixels per inches along the diagonal of the screen. This function is useful to determine the touch target size of touchable objects on the screen.
xppi : Returns pixels per inches along the x axis of the screen. This function is useful to determine the touch target size of touchable objects on the screen.
yppi : Returns pixels per inches along the y axis of the screen. This function is useful to determine the touch target size of touchable objects on the screen.

Event handlers

  • New : on.keyboardUp() which fires when the tablet's on-screen keyboard gets shown
  • New : on.keyboardDown() which fires when the tablet's on-screen keyboard gets hidden.