Mobile Development 10.11 | webMethods Mobile SuiteWeb Help | Using webMethods Mobile Designer | Creating Mobile Application Projects | Coding a Mobile Application | Migrating to the New Run-Time Classes | Binding MyCanvas with MyApplication
 
Binding MyCanvas with MyApplication
*To bind MyCanvas with MyApplication
1. Add the new private field private MyCanvas canvas to the MyApplication class.
2. Override the init() method.
a. Call super.init() to initialize Mobile Designer default specific bits.
b. Set application listener to receive Application events.
c. Create a new MyCanvas instance.
d. Register MyCanvas to receive all UI events from nUIController by calling nUIController.addEventListener(canvas, false).
3. Forward the information of the new size to the canvas instance in the onSizeChanged method.
4. Override the getMainWindow() method, and pass a new main window back.
MyApplication should now look like this :
public class MyApplication extends MDApplication implements
IMDApplicationListener
{
private MyCanvas canvas;

public void init() {
super.init();

// register for application events
setApplicationListener(this);

// create MyCanvas instance
canvas = new MyCanvas();

// register canvas to receive all UI events.
nUIController.addEventListener(canvas, false);
}

public nUIWindowDisplay getMainWindow() {

// return a new main window instance
return canvas.onCreateMainWindow();
}

public void onSizeChanged(int width, int height)
{
// forward to the canvas instance.
canvas.sizeChanged(width, height);
}

/// .... other methods