int PushButtonAdd(int cn,char *filename, int x, int y, int (*callback)(int id), int id);


Adds a push button that fires the callback immediately when the button is pushed - without waiting for it to be released. See ButtonAdd() for the typical button that fires its callback after being released.


Return Value


Returns an int handle to the button.





Specifies the container where the push button will be added.



Two image files (filename1.png and filename2.png) must be located in the folder where the exe is running. This is typically inside your Visual C++ project in your /Debug/Assets folder. A filename "Ball" specifies that "Ball1.png" and "Ball2.png" should be used to display the button in its normal and touched states respectively. The filename used with a button should not specify the extension since the internal button code will automatically append 1.png and 2.png to load the images. If the filename specified is "Images/Ball" the file will be loaded from Debug/Images/Ball1.png and Debug/Assets/Images/Ball2.png. If a path is included in the filename, it is a relative path from the Debug folder (where the exe is running from). Use forward slashes / as needed (not backslash) and never start a filename path with a slash.


NOTE: The file system used by iOS is case sensitive, so be sure to match the case of the file name in your code to that of the file on your computer.



x coordinate.



y coordinate.



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


int OnButton(int id)


   // something

  return 0;




Touch id to be sent to callback.




The PushButtonAdd() function creates a button with 2 states. Add a push button using images named <filename>1.png and <filename>2.png. You should only provide the first part of the filename and PushButtonAdd() will append 1.png and 2.png representing up and down states for the button. Do not include the extension .png with the filename because the internal button code will append 1.png and 2.png. <filename>1.png and <filename>2.png should typically be in the Debug folder with the exe.


PushButtonAdd() internally creates a view, two images and a touch that automatically manages the state of the image.


Paths to the file named in the filename parameter are relative to your application's Assets folder or to your Documents folder if the path starts with "Documents/".




Available in DragonFireSDK 2.0 and later.




This sample will add a button to the screen and each time the button is pressed, a text label on the screen will be updated with a new message.


#include "DragonFireSDK.h"


int bt;

int tx;

int ft;

int count=0;

char msg[200];


int OnButton(int id)



   sprintf(msg,"You pressed the button %d times so far!",count);





void AppMain()




   tx=TextAdd(0,10,50,"You have not yet pressed the button!",ft);



void AppExit()





void OnTimer()