{{indexmenu_n>1}} ====== POLICY OF USE OF THE EVENTS: ====== \\ - When used as attribute the name must be in lowercase and with no hyphen. - When used in Script, in Binding function, lowerCamelCase. ===== Events ===== \\ Events are applied to the following “runtime” XOne object.\\ * DataApplication (appData) * DataCollection * DataObject * View ===== Binding ===== ==== Via mapping.xml ==== \\ function onBeforeEdit (e) { …. } function onClickOk (e) { …. } function onGroupSelected (e) { } Also, a node from the mapping or collection can be executed. \\ ==== Via Script ==== \\ \\ By using the bind function (arg1, arg2, arg3) \\ \\ ===Data Events=== \\ appData.bind( eventName, eventHandler ); coll.bind( eventName, eventHandler ); obj.bind( propName, eventName, eventHandler ); ===UI Events=== \\ ui.getView(obj).bind (controlName, eventName,eventHandler) function onClickOk (e) { // some stuff ... } function onBeforeEdit (e) { // some stuff ... } function prepareBinding () { var myColl = appData.getCollection(“MyColl”); var myObject = myColl.createObject(); /* ********************************** */ // Asociar eventos a nivel de COLL /* ********************************** */ myColl.bind ( “onbeforeedit”, onBeforeEdit); myColl.bind ( “ongroupselected”, onGroupSelected); /* ********************************** */ // Asociar eventos a Propiedades /* ********************************** */ var uiView = ui.getView(myObject); // uiview sería NULL si el objeto no se está mostrando uiView.bind (“BUTONOK”, “onclick”, onClickOk); uiView.bind (“BUTONOK”, “onclick”, function (e) { // some stuff ... }); // Si las propiedades a las que queremos referenciar no están en una ventana visible, tendríamos que utilizar: myColl.bind ( “onbeforeedit”, function (e) { currentView.bind (“BUTONOK”, “onclick”, onClickOk); currentView.bind (“BUTONOK”, “onclick”, function (e) { // some stuff ... }); }); appData.pushValue(myObject); } ===== List of Available Events ===== ====Application (appData) System events==== \\ |< 80% 10% 10% - >| ^ **Event ** ^ **XML Code ** ^ **Description** ^ | | | Developing| ====DataObject==== \\ |< 80% 10% 10% - >| ^ **Event ** ^ **XML Code ** ^ **Descripction** ^ | | | Developing | ====DataCollection, DataObject, UI Events ==== \\ |< 80% 20% - >| ^ **Event ** ^ **Description** ^ | | Developing | ====DataObject (props) UI Events ==== \\ |< 80% 10% 10% - >| ^ **Event ** ^ **Property** ^ **Description** ^ | onclick | type="B" | Invoking when pressing a button. | | onTextChanged | type="T" | Invoking while you are pressing characters on the keyboard.\\ Parameters: target, objItem, newText, oldText, keyPressed | | onFocusChanged| type="T" | Invoking when the field loses or gains focus, at the isFocused parameter. Parameters: target, objItem, isFocused | ===Onclick Code Example=== \\ At the time to define an event, we will do it as attribute in the XML of the prop or with the bind method, we **DO NOT** use both at the same time. l * If the event is declared as attribute in the XML it will be written in lowercase (onclick) * If the event is declared with the bind method, it will be written in lowerCamelCase (onClick) As attribute in the XML: In the bind method: var v=ui.getView(self); //Así obtenemos una referencia a la ventana actual de la aplicación v.bind ("MAP_BTN1","onClick","collTest1",jstestClick); In some external .js file, we will have the javascript function to which is called from the onclick attribute or from the bind method: function jstestClick(e,data) { var c; ui.msgBox ("Abre el objeto "+data,"Titulo",0); c=appData.getCollection(data); var obj=c.createObject(); c.addItem(obj); appData.pushValue(obj); } ====DataObject (props) Data Events==== \\ |< 80% 10% 10% - >| ^ **Event ** ^ **Property** ^ **Description** ^ | | | Developing | ====DataObject (frame) UI Events==== \\ |< 80% 8% 8% 40% - >| ^ Event ^ Node ^ Event Parameters ^ Description ^ | onScroll|frame |**target**: Distance left to make horizontal scroll.\\ **dx**: Distance left to make horizontal scroll .\\ **dy**: Distance left to make vertical scroll. \\ **width**: width of the area that is scrolled. \\ **height**: height of the area that is scrolled. \\ **scrollX**: distance moved horizontally. \\ **scrollY**: distance moved vertically. \\ | It allows you to control the vertical and horizontal movements in the frames that have Pscroll=”true”.| **Example of code of the onScroll event in a frame:**