int ViewAdd(int im,int x,int y,int (*callback)(int id,int event,int x,int y),int id);

 

Add a View and attach the Image im (the handle returned by ImageAdd()) to the View.

 

Return Value

 

Returns an int handle to the view.

 

Parameters

 

im

Image handle returned from ImageAdd().

 

x

X coordinate.

 

y

Y coordinate.

 

callback

Specifies a function that will be called when the image in this view is touched.

 

int OnBall(int id, int event, int x, int y)     //event: 1=down, 2=move, 3=up

{

       if (event == 3)

       {   // touch up (touched and released)

               //...do something

       }

       return 0;

}

 

id

Touch id to be sent to callback.

 

Remarks

 

The ViewAdd() function makes an image visible. Use ImageAdd() to load an image.

 

Availability

 

Available in DragonFireSDK 2.0 and later.

 

Example

 

This example adds a view with an image of a card to the screen and sets a callback.

 

#include "DragonFireSDK.h"

 

int im;

 

int OnTouch(int id,int event,int x, int y)

{

       printf("You touched the card!\n");

       return(id);

}

 

void AppMain()

{

       im=ImageAdd("Cards/Card01.png");

       ViewAdd(im,0,0,OnTouch,1);

}

 

void AppExit()

{

 

}

 

void OnTimer()

{

 

}