banner
Scripting Gestures

I. General


II. API

MozGest 2.x MozGest 3.x
globalSrcEvent
The event that started the gesture.

Example:
alert(globalSrcEvent.originalTarget);
Install Example (RD)
globalSrcEvent
mgGestureState.srcEvent
 
mgGestureState.endEvent
The event that finished the gesture.
Can be null.

Example:
if (mgGestureState.endEvent)
  alert(mgGestureState.endEvent.originalTarget);
Install Example (RD)
globalOnLink
An array holding the hovered link nodes.
Can be false.
Can have a length of 0.

Example:
if (!globalOnLink || globalOnLink.length < 1)
  return;

for (var count = 0; count < globalOnLink.length; count++)
  alert(globalOnLink[count].href);
Install Example (*RD)
globalOnLink
 
mgGestureState.linkCollection
An associative array holding the hovered links.

Example:
if ("mgGestureState" in window) { //check for MozGest 3.x
  var gs = mgGestureState;
  for (each in gs.linkCollection) {
    alert(each);
    alert(gs.linkCollection[each].nodeName);
  }
}
Install Example (*RD)
globalOnImage
The first (and only the first) hovered image node.
Can be false.

Example:
if (globalOnImage) {
  var browser = getBrowser();
  var referrer = null;
  var tab = browser.addTab(globalOnImage.src, referrer, null);
  browser.selectedTab = tab;
}
Install Example (RD)
globalOnImage
 
mgGestureState.imageCollection
An associative array holding the hovered images.

Example:
if ("http://xyz..." in mgGestureState.imageCollection)
  alert("found");
else
  alert("not found");
Install Example (*RD)
mgGetSelection()
Returns the current selection of the view the gesture started in.

Example:
var sel = mgGetSelection();

if (sel != "")
  alert(sel);
Install Example (RD)
mgGetSelection()
mgShowStatus(reserved, string myMessage)
Displays the status notification.
Long messages will be cropped.
Don't use 'reserved'. Pass null instead.

Example:
var myMessage = mgGetSelection();

if (myMessage != "") {
  if ("mgGestureHelper" in window)
    mgGestureHelper.showStatus(null, myMessage);
  else
    mgShowStatus(null, myMessage);
}
Install Example (RD)
mgShowStatus(reserved, string myMessage)
Doesn't work in MozGest 3.0.0.
Use mgGestureHelper.showStatus instead.
Fixed in MozGest 3.0.1.
mgAppInfo
Holds information about the application and MozGest.

Example:
for (each in mgAppInfo) {
  if (each != "init")
    alert("mgAppInfo." + each + ":\n" + mgAppInfo[each]);
}
Install Example (RD)
mgAppInfo

III. Using built-in functions

The built-in functions (e.g. mgB_ZoomIn()) are located in chrome://mozgest/content/gestimp.js .

Starting with MozGest 3.0 these functions are NOT global anymore!
They are now guarded by "mgBuiltInFunctions", "mgGestureFunctions" or something else (e.g. mgBuiltInFunctions.mgB_ZoomIn()).

To keep compatibility with existing scripts, MozGest 3 will do some "magic", so you MUST NOT use "mgBuiltInFunctions." inside of custom scripts.

IV. Some scripts for learning