Access Keys:
Skip to content (Access Key - 0)
iServoy.com | Servoy.com | Forum index | Store | Developers | Documentation | Events | Products | Support

JSEvent

All versions
Click for all versions
Servoy 5.0.x
Toggle Sidebar
This documentation relates to an earlier version of Servoy
View this page in the current documentation or visit the current documentation home.

\\
Constants Summary
StringACTION
Constant returned by JSEvent.
StringDATACHANGE
Constant returned by JSEvent.
StringDOUBLECLICK
Constant returned by JSEvent.
StringFOCUSGAINED
Constant returned by JSEvent.
StringFOCUSLOST
Constant returned by JSEvent.
StringFORM
Constant returned by JSEvent.
NumberMODIFIER_ALT
Constant for the ALT modifier that can be returned by JSEvent.
NumberMODIFIER_CTRL
Constant for the CTRL modifier that can be returned by JSEvent.
NumberMODIFIER_META
Constant for the META modifier that can be returned by JSEvent.
NumberMODIFIER_SHIFT
Constant for the SHIFT modifier that can be returned by JSEvent.
StringNONE
Constant returned by JSEvent.
StringONDRAG
Constant returned by JSEvent.
StringONDRAGOVER
Constant returned by JSEvent.
StringONDROP
Constant returned by JSEvent.
StringRIGHTCLICK
Constant returned by JSEvent.
\\
Property Summary
Objectdata
A data object that specific events can set, a user can set data back to the system for events that supports this.
\\
Method Summary
StringgetElementName()
returns the name of the element, can be null if the form was the source of the event.
StringgetFormName()
returns the name of the form the element was placed on.
NumbergetModifiers()
Returns the modifiers of the event, see JSEvent.
ObjectgetSource()
returns the source component/element of the event.
DategetTimestamp()
Returns the time the event occurred.
StringgetType()
returns the event type see the JSEvents constants what it can return.
NumbergetX()
Returns the x position of the event if applicable.
NumbergetY()
Returns the x position of the event if applicable.
\\
Constants Details
ACTION

Constant returned by JSEvent.getType() in a method that is attached to an onAction event.

Returns

String

Sample
if (event.getType() == JSEvent.ACTION) 
{
   // its an action event.
}
DATACHANGE

Constant returned by JSEvent.getType() in a method that is attached to an onDataChange event.

Returns

String

Sample
if (event.getType() == JSEvent.DATACHANGE) 
{
   // its a data change event
}
DOUBLECLICK

Constant returned by JSEvent.getType() in a method that is attached to an onDoubleClick event.

Returns

String

Sample
if (event.getType() == JSEvent.DOUBLECLICK) 
{
   // its a double click event.
}
FOCUSGAINED

Constant returned by JSEvent.getType() in a method that is attached to an onFocusGained or the forms onElementFocusGained event.

Returns

String

Sample
if (event.getType() == JSEvent.FOCUSGAINED) 
{
   // its a focus gained event.
}
FOCUSLOST

Constant returned by JSEvent.getType() in a method that is attached to an onFocusLost or the forms onElementFocusLost event.

Returns

String

Sample
if (event.getType() == JSEvent.FOCUSLOST) 
{
   // its a focus lost event.
}
FORM

Constant returned by JSEvent.getType() in a method that is attached to a form event (like onShow) or command (like onDeleteRecord)

Returns

String

Sample
if (event.getType() == JSEvent.FORM) 
{
   // its a form event or command
}
MODIFIER_ALT

Constant for the ALT modifier that can be returned by JSEvent.getModifiers();

Returns

Number

Sample
//test if the SHIFT modifier is used.
if (event.getModifiers() & JSEvent.MODIFIER_SHIFT)
{
	//do shift action
}
MODIFIER_CTRL

Constant for the CTRL modifier that can be returned by JSEvent.getModifiers();

Returns

Number

Sample
//test if the SHIFT modifier is used.
if (event.getModifiers() & JSEvent.MODIFIER_SHIFT)
{
	//do shift action
}
MODIFIER_META

Constant for the META modifier that can be returned by JSEvent.getModifiers();

Returns

Number

Sample
//test if the SHIFT modifier is used.
if (event.getModifiers() & JSEvent.MODIFIER_SHIFT)
{
	//do shift action
}
MODIFIER_SHIFT

Constant for the SHIFT modifier that can be returned by JSEvent.getModifiers();

Returns

Number

Sample
//test if the SHIFT modifier is used.
if (event.getModifiers() & JSEvent.MODIFIER_SHIFT)
{
	//do shift action
}
NONE

Constant returned by JSEvent.getType() if the event is not used in a known event or command.

Returns

String

Sample
if (event.getType() == JSEvent.NONE) 
{
   // type is not set.
}
ONDRAG

Constant returned by JSEvent.getType() in a method that is attached to an onDrag event.

Returns

String

Sample
if (event.getType() == JSEvent.ONDRAG) 
{
   // its an ondrag event
   if (event.getElementName() == 'todragelement')
   	return DRAGNDROP.COPY
}
ONDRAGOVER

Constant returned by JSEvent.getType() in a method that is attached to an onDragOver event.

Returns

String

Sample
if (event.getType() == JSEvent.ONDRAGOVER) 
{
   // its an on drag over event.
   // return true if it over the right element.
   return event.getElementName() == 'candroponelement';
}
ONDROP

Constant returned by JSEvent.getType() in a method that is attached to an onDrop event.

Returns

String

Sample
if (event.getType() == JSEvent.ONDROP) 
{
   // its a on drop event.
   var element = elements[event.getElementName()];
   // do drop on element
   return true;
}
RIGHTCLICK

Constant returned by JSEvent.getType() in a method that is attached to an onRightClick event.

Returns

String

Sample
if (event.getType() == JSEvent.RIGHTCLICK) 
{
   // its a right click event.
}
\\
Property Details
data

A data object that specific events can set, a user can set data back to the system for events that supports this.

Returns

Object

Sample
// A client design method that handles ondrag
if (event.getType() == JSEvent.ONDRAG)
{
     // the data is the selected elements array
     var elements = event.data;
     // only start a client design drag when there is 1 element
     if (elements.length == 1)
     {
     	return true;
     }
}

// code for a data drag method
event.data = "drag me!";
return DRAGNDROP.COPY;

// code for a data drop method
var data = event.data;
elemements[event.getElementName()].setText(data);
return true;

Method Details
getElementName
StringgetElementName()

returns the name of the element, can be null if the form was the source of the event.

Returns

String – a String representing the element name.

Sample
if (event.getElementName() == 'myElement')
{
    elements[event.getElementName()].bgcolor = '#ff0000';
}
getFormName
StringgetFormName()

returns the name of the form the element was placed on.

Returns

String – a String representing the form name.

Sample
forms[event.getFormName()].myFormMethod();
getModifiers
NumbergetModifiers()

Returns the modifiers of the event, see JSEvent.MODIFIER_XXXX for the modifiers that can be returned.

Returns

Number – an int which holds the modifiers as a bitset.

Sample
//test if the SHIFT modifier is used.
if (event.getModifiers() & JSEvent.MODIFIER_SHIFT)
{
	//do shift action
}
getSource
ObjectgetSource()

returns the source component/element of the event.
If it has a name the getElementName() is the name of this component.

Returns

Object – an Object representing the source of this event.

Sample
var sourceDataProvider = event.getSource().getDataProviderID();
getTimestamp
DategetTimestamp()

Returns the time the event occurred.

Returns

Date – a Date when this event happened.

Sample
event.getTimestamp();
getType
StringgetType()

returns the event type see the JSEvents constants what it can return.
Plugins can create events with there own types.

Returns

String – a String representing the type of this event.

Sample
if (event.getType() == JSEvent.ACTION) 
{
   // its an action event.
}
getX
NumbergetX()

Returns the x position of the event if applicable.
For example drag'n'drop events will set the x,y positions.

Returns

Number – an int representing the X position.

Sample
var x = event.getX();
var xPrevious = previousEvent.getX();
var movedXPixels = x -xPrevious;
getY
NumbergetY()

Returns the x position of the event if applicable.
For example drag'n'drop events will set the x,y positions.

Returns

Number – an int representing the Y position.

Sample
var y = event.getY();
var yPrevious = previousEvent.getY();
var movedYPixels = y -yPrevious;

Visit our website at http://www.servoy.com or read our blogs at http://www.servoy.com/blog
Powered by Atlassian Confluence (w/ Adaptavist Theme Builder) | Terms of Use | Privacy Policy