Player APIs (BrightScript & Ja...
...
Object Reference
Presentation and Widget Object...

roTouchScreen

23min
this object accepts inputs from touchscreen panels or mice for each recognized input, the object will generate an rotouchevent object see the "rotouchscreen" section of the brightscript javascript migration guide docid 2kewwxlmpycwu8tffuf2z for the equivalent methods in javascript not all touchscreens are supported please see touchscreens docid\ acl5v8 jqiuq3sntxsnfo for a full list of supported touchscreens the rotouchscreen object responds to the clicks of a usb mouse in the same way it responds to touch events on a touchscreen to set up touchscreen/mouse interactivity, follow this outline create an rotouchscreen instance use setport() to specify an romessageport instance to receive the rotouchscreen events define one or more touch regions a touch region may be rectangular or circular when a touch or click occurs anywhere inside the area of a touch region, an event will be sent to the message port if touch regions overlap such that a click or touch hits multiple regions, an event for each affected region will be sent process the events the rotouchscreen object supports rollover regions rollovers are based around touch regions when a rectangular or circular region is added, it defaults to having no rollover you can use the enablerollover() method to add an on and off image for a region whenever the mouse cursor is within that region, the on image is displayed in all other cases, the off image is displayed this allows buttons to be highlighted as the mouse cursor moves over them iftouchscreen setresolution(x as integer, y as integer) as void addrectangleregion(x as integer, y as integer, w as integer, h as integer, region id as integer) as void adds a rectangular touch region to the screen the region id is used to associate the touch region with rotouchevent events and to link the region with rollover images addcircleregion(x as integer, y as integer, radius as integer, region id as integer) as void adds a circular touch region to the screen the region id is used to associate the touch region with rotouchevent events and to link the region with rollover images clearregions() as void clears the list of regions added using addrectangleregion() or addcircleregion() so that any contacts in those regions no longer generate events this call has no effect on the rollover graphics getdevicename() as string setcursorposition(x as integer, y as integer) as void setcursorbitmap(filename as string, x as integer, y as integer) as void specifies a bmp or png file as the mouse cursor icon this method also accepts a "hot spot" (i e the point within the icon rectangle that will trigger events when the mouse is clicked) as a set of x,y coordinates the icon can be a rectangle of any width or height enablecursor(enable as boolean) as void displays a cursor on screen if passed true enablerollover(region id as integer, on image as string, off image as string, cache image as boolean, image player as object) as void enables a rollover for a touch region this method accepts the id of the touch region, as well as two strings specifying the names of the on and off bitmap images, a cache setting, and the image player that draws the rollover the cache image parameter simply tells the script whether to keep the bitmaps loaded in memory or not this setting uses up memory very quickly, so we recommend that cache image normally be set to 0 setrolloverorigin(region id as integer, x as integer, y as integer) as void changes the origin so that more (or less) of the screen changes when the mouse rolls in and out of the region this means that bitmaps that are larger than the region can be drawn the default requirement is that rollover bitmaps be the same size and position as the touch region note that the bitmap is square for circular regions the default origin for circular regions is \[x r] , \[y – r], where x , y is the center of the circle, and r is the radius the enablerollover() and setrolloverorigin() methods have been deprecated as of os8, the end points exist but do not perform any function enableregion(region id as integer, enabled as boolean) as void enables or disables a rollover region this method accepts the id of the touch region, as well as a boolean value (true or false) the rollover regions default to "enabled" when created, but you can set up all of the regions at the start of your script and then enable regions as required ismousepresent() as boolean returns true if a relative pointing device is attached to the player this does not work for absolute devices like touchscreens setmouserotation(rotation as integer) as boolean transforms mouse movement inputs to account for screen rotation this method can accept the following integers 0 inputs are unchanged (i e landscape orientation) 1, 90 rotated 90 degrees (i e clockwise portrait orientation) 2, 180 rotated 180 degrees 3, 270 rotated 270 degrees (i e counter clockwise portrait orientation) enableserialtouchscreen(a as integer) as boolean setserialtouchscreenconfiguration(a as string) as boolean getdiagnosticinfo() as string returns an html string with captured information describing hardware that was connected and events that occurred during the calibration process this method is used by the calibration script to diagnose touchscreen issues ifsetmessageport setport(port as romessageport) posts messages of type rotouchevent and rotouchcalibrationevent to the attached message port iftouchscreencalibration startcalibration() as boolean getcalibrationstatus() as integer getdiagnosticinfo() as string clearstoredcalibration() as boolean starteventlogging() as boolean stopeventlogging() as boolean cleareventlogs() as boolean setcalibrationranges(x min as integer, x max as integer, y min as integer, y max as integer) as boolean overrides the screen range values provided by the touchscreen this method is useful when the entirety of the video output is not being displayed on the touch surface practical use of this method usually requires a custom calibration script, appropriate images, and a calibration setting matched to a particular setup ifserialcontrol setbaudrate(baud rate as integer) as boolean sets the baud rate of the device the supported baud rates are as follows 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400 notused1(a as string) setmode(a as string) as boolean notused2(a as boolean) as boolean examples this script loops a video and waits for a mouse click or touchscreen input it outputs the coordinates of the click or touch to the shell if it is located within the defined region v=createobject("rovideoplayer") t=createobject("rotouchscreen") p=createobject("romessageport") v setport(p) t setport(p) v setloopmode(true) v playfile("testclip mp2v") t addrectangleregion(0,0,100,100,2) loop msg=wait(0, p) print "type ";type(msg) print "msg=";msg if type(msg)="rotouchevent" then print "x,y=";msg getx();msg gety() endif goto loop this script includes mouse support t=createobject("rotouchscreen") t setport(p) rem puts up a cursor if a mouse is attached rem the cursor must be a 16 x 16 bmp rem the x,y position is the "hot spot" point t setcursorbitmap("cursor bmp", 16, 16) t setresolution(1024, 768) t setcursorposition(512, 389) rem rem pass enable cursor display true for on, and false for off rem the cursor will only enable if there is a mouse attached rem t enablecursor(true) this script includes a rollover region and mouse support img=createobject("roimageplayer") t=createobject("rotouchscreen") p=createobject("romessageport") t setport(p) t setcursorbitmap("cursor bmp", 16, 16) t setresolution(1024, 768) t setcursorposition(512, 389) t enablecursor(true) img displayfile("\menu bmp") rem adds a rectangular touch region rem enables rollover support for that region rem sets the rollover origin to the same position as the touch region rem t addrectangleregion(0, 0, 100, 100, 1) t enablerollover(1, "on bmp", "off bmp", true, img) t setrolloverorigin(1, 0, 0)