User Tools

Site Tools


en:wiki:2.-desarrollo-app:2.3.-codigo:b.-controles-xone:4.-botones:start



Buttons


It is for the creation of buttons, which actions can be executed with. The prop to define a button is made with the type=“B” attribute.

The creation of a button has two parts: on the one hand, the property that defines its visual attributes, and on the other, a node where will be each one of the actions to be made.


Here, the button node is shown. Besides the attributes that decice if it is visible, the title to be shown on screen or in which group it is shown, we have the method attribute, that is a very important attribute, since it is the place where we make the call to the node that executes the button actions.

    <prop name="BUTTON1" group="3" type="B" method="ExecuteNode (inicializar)" title="Iniciar Ruta" visible="1" toolbar="false" labelwidth="24"  onchange="refresh255" lmargin="7"/>
 
    <!-- boton con imagen atributo img, width y height  -->
    <prop name="Buscar" group="1" type="B" title="Buscar" visible="1" method="ExecuteNode(buscar)" class="boton" labelwidth="1" img="search.png" width="50" height="50" />
 
    <!-- Anteriormente existía el nodo button con las mismas funcionalidades del prop type="B" que ya está obsoleto
     y no se interpretan muchos de los estilos definidos con css y tampoco atributos nuevos. 
   -->
   <button name="BUTTON1" group="3" method="ExecuteNode (inicializar)" caption="Iniciar Ruta" visible="1" toolbar="false" labelwidth="24"/>
 


Themethod name=“ExecuteNode“ node, is a system node, y it is already DEPRECATED in all the Framework. Currently only it is mandatory in the PC Framework. Only it is put once in the collection that has buttons and it is always the same.

<method name="ExecuteNode">
    <param name="P1" type="T" value=""/>
</method>


And finally, the node where the code that is going to be executed is put. The name is defined by the user, and as only requirement is that the node name has to be the same (upper-case and lower-case) than the node to which the button node calls in its method attribute. At the example, are shown some actions made with Script code, but we could have put action nodes instead.

Example of Code


<inicializar>
    <action name="runscript">
        <script language="VBScript">
            Dim vResult
            vResult =AppData.UserInterface.MsgBox ("Esta acción reiniciará toda la ruta. ¿Está seguro que desea ejecutarla?","Advertencia",1)
            If vResult =1 Then 	
                'OJO, el update va a meter las operaciones en réplica, si no se desea, mirar el código definido en maintenance.			
                appdata.executeSQL "UPDATE Gen_Rutas SET VISITADO=0 WHERE IDUSUARIO=" + CStr(This("IDUSUARIO"))
                vResult =AppData.UserInterface.MsgBox ("Ruta inicializada","Advertencia",0)
            End If							
        </script>
    </action>
</inicializar>
 
<prop name="MAP_BT_CITAS_MEDICAS" method="executenode(irgroup(8))" type="B" visible="1" width="120" height="95" labelwidth="1" newline="false" img=".\icons\tr.png" imgsel=".\icons\trsel.png" />
<prop name="MAP_BT_VIVIR_BIEN" method="executenode(irColl(VivirBien))" type="B" visible="1" width="120" height="95" labelwidth="1" img=".\icons\tr.png" imgsel=".\icons\trsel.png" />
 
<!-- Con este nos vamos a otra pestaña dentro de la misma colección -->
<irgroup>
	<action name="runscript">
	<param name="group" />
		<script language="VBScript">
			this("MAP_NGROUP") = group
			'appdata.UserInterface.MsgBox this("MAP_GROUP"),"",0
			AppData.UserInterface.ShowGroup group,"##ALPHA_IN##",500,"##ALPHA_OUT##",500
		</script>
	</action>
</irgroup>
 
<!-- Con este nos vamos a otra colección -->
<irColl>
	<action name="runscript">
	<param name="coll" />
		<script language="VBScript">
			'ui.openmenu "coleccion",mascara,modo (0-listado, 1-Edicion)
			appData.userinterface.openmenu coll,26,1
		</script>
	</action>
</irColl>
 
<mensajes show-wait-dialog="false">
	<action name="runscript">
		<script language="VBScript">
			'MsgBox0,MsgBox1,MsgBox4,ShowToast,ShowNotification,Sonido
			Dim vResult
			Select Case this("MAP_TIPO_MENSAJE")
			Case "MsgBox0"
				ui.MsgBox "Mensaje Informativo solo con OK","Titulo Ventana",0
			Case "MsgBox1"
				'Si pulsa ACEPTAR vale 1 y si pulsa CANCELAR vale 2
				vResult =ui.MsgBox ("Pregunta si ACEPTAR ó CANCELAR","Advertencia",1)
				ui.MsgBox "Ha pulsado el botón con valor: "+cstr(vResult),"Titulo Ventana",0
			Case "MsgBox4"
				'Si pulsa SI vale 6 y si pulsa NO vale 7
				vResult =ui.MsgBox ("Pregunta SI ó NO","Advertencia",4)
				ui.MsgBox "Ha pulsado el botón con valor: "+cstr(vResult),"Titulo Ventana",0
			Case "ShowToast"
				ui.showToast "Mensajito efímero que dura 3 segundos"
			Case "ShowNotification"
				ui.ShowNotification 1, "Título", "Esto es una notificación", "Aviso de recepción de datos"
			Case "Sonido"
				'El sonido tiene que estar en la carpeta files del proyecto
				ui.PlaySoundAndVibrate "bultonoencontrado.wav",true,1
			End Select
		</script>
	</action>
</mensajes>

Attributes

method="ExecuteNode (nodo name)"


Attribute that calls to the node which will execute the corresponding instructions.

This method can be passed parameters, in such way that several buttons can call to a same code with slight variations…

<prop type="B" ..... method="executeNode (sacamsg(Parametro1,Parametro2))" />
<sacamsg>
	<action name="runscript">
		<param name="parametro1" />
		<param name="parametro2" />
		<script language="VBScript">
			if parametro1="loquesea" then
				......
			end if
			llamadaafuncion parametro1 parametro2
		</script>
	</action>
</sacamsg>

title="name"


Button name.

postonchange="refresh"


The postonchange is an attribute specified to be executed when we return to the normal flow of the application after a pushvalue, in order some node is executed or to refresh the properties in case any has been modified during the pushvalue.

Example of Code:

<prop name="Aceptar" type="B" title="Aceptar" onchange="Refresh" method="ExecuteNode(aceptar)" postonchange="ExecuteNode(postaceptar)" ... /> 


At the <aceptar> node a pushvalue is launched, and when returning from the pushvalue the postonchange=”ExecuteNode(postaceptar)” would be executed or making a postochange=“refresh” to refresh the properties in the event any of them had changed value during the pushvalue.

If a pushvalue is done from a before-edit, the postonchange has to be put in the node itself.

<before-edit postonchange="refresh">
	-------
	-------
</before-edit> 
en/wiki/2.-desarrollo-app/2.3.-codigo/b.-controles-xone/4.-botones/start.txt · Last modified: 2018/02/28 09:21 by patricia