User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

sample_code:extra_keys

Extra keys

This code snippet offers an extra line of keys to make some extra keys easier to get at.

It uses new features added in v1.09 beta, so will not work on release version 1.05

keys.js
//keys.js
var gEdt;
//Called when application is started.
function OnStart()
{
  //Create a layout with objects vertically centered.
  lay = app.CreateLayout("linear", "Vcenter,FillXY");
 
  //Create a text edit and add it to layout.
  edt = app.CreateTextEdit("Hello");
  edt.SetTextSize(32);
  lay.AddChild(edt);
  //Create a checkbox for overstrike mode
  chkOvertype = app.CreateCheckBox("Overtype");
  lay.AddChild(chkOvertype);
  //create a horizontal layout for special characters
  lay_keys = app.CreateLayout("linear", "Horizontal,FillY");
  btns = []
  var ks = '{}[]();#"' + "'"
  for (i = 0; i < ks.length; i++)
  {
    var ch = ks.charAt(i);
    btn = app.CreateButton(ch);
    btn.SetOnTouch(btn_OnTouch);
    lay_keys.AddChild(btn);
    btns.push(btn);
  }
  lay.AddChild(lay_keys);
 
  //Add layout to app.    
  app.AddLayout(lay);
  gEdt = edt;
}
 
function btn_OnTouch()
{
  var s = this.GetText();
  var pos = gEdt.GetCursorPos();
  var theEnd = gEdt.GetText().length;
  if (!chkOvertype.GetChecked())
  {
    gEdt.InsertText(s, pos);
  }
  else
  {
    gEdt.ReplaceText(s, pos, Math.min(pos + s.length, theEnd));
    gEdt.SetCursorPos(pos + s.length);
  }
}
sample_code/extra_keys.txt · Last modified: 2014/12/07 04:56 (external edit)