Difference between revisions of "Komodo Macro"

From WebOS Internals
Jump to navigation Jump to search
m (starting to update with documentation)
m
Line 21: Line 21:
 
== Deploy Functions ==
 
== Deploy Functions ==
  
A list of the deploy functions which will automatically toggle and animate the add-on to prevent conflicts. These cannot be modified as they function is a very specific way.
+
The deploy functions which will automatically toggle and animate the add-on to prevent conflicts.  
  
 
<source lang="javascript">
 
<source lang="javascript">
 +
// Emulator Functions
 
ko.extensions.webos.emulator.packageInstallLaunch();
 
ko.extensions.webos.emulator.packageInstallLaunch();
 
ko.extensions.webos.emulator.packageInstallInspect();
 
ko.extensions.webos.emulator.packageInstallInspect();
Line 29: Line 30:
 
ko.extensions.webos.emulator.launch();
 
ko.extensions.webos.emulator.launch();
 
ko.extensions.webos.emulator.close();
 
ko.extensions.webos.emulator.close();
 +
// Device Functions
 
ko.extensions.webos.device.packageInstallLaunch();
 
ko.extensions.webos.device.packageInstallLaunch();
 
ko.extensions.webos.device.remove();
 
ko.extensions.webos.device.remove();
Line 35: Line 37:
 
</source>
 
</source>
  
== Custom Deploy functions ==
+
The above functions can optionally be passed an object with onSuccess and onFailure property functions.
  
All deploy functions are asynchronous with onSuccess and onFailure callbacks.
+
<source lang="javascript">
 +
{
 +
    onSuccess:function()
 +
    {
 +
        // This means the function worked
 +
    },
 +
    onFailure:function()
 +
    {
 +
        // This means the function failed the UI will show this also.
 +
    }
 +
}
 +
</source>
 +
 
 +
For more customization you must use the base palm functions listed below.
 +
 
 +
== Macro Functions ==
 +
 
 +
All functions are asynchronous with onSuccess and onFailure callbacks. These are written to make the more complicated tasks very simple to write into a macro.
  
=== Is Emulator Connected ===
+
=== Check If Connected ===
 +
 
 +
==== Is Emulator Connected ====
  
 
The first thing you need to determine is if the emulator or device is connected.
 
The first thing you need to determine is if the emulator or device is connected.
Line 56: Line 77:
 
</source>
 
</source>
  
=== Is Device Connected ===
+
==== Is Device Connected ====
  
 
<source lang="javascript">
 
<source lang="javascript">
Line 67: Line 88:
 
     {
 
     {
 
         // Emulator was not found
 
         // Emulator was not found
 +
    }
 +
});
 +
</source>
 +
 +
=== Palm Commands ===
 +
 +
You may have never used the palm command line since you are use to the add-on, but the following are what the quick buttons rely on.
 +
 +
==== Package Application ====
 +
 +
Package an application automatically into either the bin/release or bin/debug based on the framework_config.json settings.
 +
 +
<source lang="javascript">
 +
ko.extensions.webos.palm.packageApplication({
 +
    onSuccess:function()
 +
    {
 +
        // Created the ipk package file
 +
    },
 +
    onFailure:function()
 +
    {
 +
        // Failed to create package
 
     }
 
     }
 
});
 
});
 
</source>
 
</source>

Revision as of 05:13, 15 March 2010

Macros show up in the toolbox panel on the right hand side of the Komodo window. They can be used to automate almost everything in Komodo, and with the Komodo add-on all the functionality are extended to the macros.

Since users are use to writing javascript from their Mojo applications all macros are written in JavaScript (Python is also allowed, but not documented).

If you do not see the panel: View > Tabs & Sidebars > Toolbox.

Macro Basics

To create a new macro... [fill this in]

Add a new Macro to the Toolbox

<source lang="javascript"> komodo.assertMacroVersion(2); // Macro Version if(komodo.view && komodo.view.scintilla) {

   komodo.view.scintilla.focus(); // Sets focus

} </source>

Deploy Functions

The deploy functions which will automatically toggle and animate the add-on to prevent conflicts.

<source lang="javascript"> // Emulator Functions ko.extensions.webos.emulator.packageInstallLaunch(); ko.extensions.webos.emulator.packageInstallInspect(); ko.extensions.webos.emulator.remove(); ko.extensions.webos.emulator.launch(); ko.extensions.webos.emulator.close(); // Device Functions ko.extensions.webos.device.packageInstallLaunch(); ko.extensions.webos.device.remove(); ko.extensions.webos.device.launch(); ko.extensions.webos.device.close(); </source>

The above functions can optionally be passed an object with onSuccess and onFailure property functions.

<source lang="javascript"> {

   onSuccess:function()
   {
       // This means the function worked
   },
   onFailure:function()
   {
       // This means the function failed the UI will show this also.
   }

} </source>

For more customization you must use the base palm functions listed below.

Macro Functions

All functions are asynchronous with onSuccess and onFailure callbacks. These are written to make the more complicated tasks very simple to write into a macro.

Check If Connected

Is Emulator Connected

The first thing you need to determine is if the emulator or device is connected.

<source lang="javascript"> ko.extensions.webos.palm.isEmulatorConnected({

   onSuccess:function()
   {
       // Emulator was found
   },
   onFailure:function()
   {
       // Emulator was not found
   }

}); </source>

Is Device Connected

<source lang="javascript"> ko.extensions.webos.palm.isDeviceConnected({

   onSuccess:function()
   {
       // Emulator was found
   },
   onFailure:function()
   {
       // Emulator was not found
   }

}); </source>

Palm Commands

You may have never used the palm command line since you are use to the add-on, but the following are what the quick buttons rely on.

Package Application

Package an application automatically into either the bin/release or bin/debug based on the framework_config.json settings.

<source lang="javascript"> ko.extensions.webos.palm.packageApplication({

   onSuccess:function()
   {
       // Created the ipk package file
   },
   onFailure:function()
   {
       // Failed to create package
   }

}); </source>