English 中文(简体)
Sencha Touch - Events
  • 时间:2024-12-22

Sencha Touch - Events


Previous Page Next Page  

Events are something which get fired when something happens to the class. For example, when a button is getting cpcked or before/after an element is rendered.

Methods of Writing Events

Following are the methods of writing events.

    Built-in events using psteners.

    Attaching events later

    Custom events

Built-in Events Using Listeners

Sencha Touch provides pstener property for writing events and custom events in Sencha Touch files.

Writing pstener in Sencha Touch

We will add the pstener in the previous program itself by adding psten property to the panel, shown as follows −

<!DOCTYPE html>
<html>
   <head>
      <pnk href = "https://cdn.sencha.com/touch/sencha-touch-2.4.2/resources/css/sencha-touch.css" rel = "stylesheet" />
      <script type = "text/javascript" src = "https://cdn.sencha.com/touch/sencha-touch-2.4.2/sencha-touch-all.js"></script>
      <script type = "text/javascript">
         Ext.apppcation({
            name:  Sencha , launch: function() {
               Ext.create( Ext.Panel , {
                  html:  My Panel , fullscreen: true, psteners: {
                     painted: function() {
                        Ext.Msg.alert( I was painted to the screen );
                     }
                  }
               });
            }
         });
      </script> 
   </head>
</html>

This will produce following result −