int ButtonAdd(int cn,char *filename, int x, int y, int (*callback)(int id), int id);
Adds a button that fires the callback after then button has been touched and then released to the specified container. See PushButtonAdd() for a button that fires its callback immediately after being touched without waiting for release.
Returns an int handle to the button.
Specifies the container where the 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 within the container.
y coordinate within the container.
Specifies a function that will be called when the image in this button is touched.
int OnButton(int id)
Touch id to be sent to callback.
The ButtonAdd() function creates a button with 2 states. Add a Button using images named <filename>1.png and <filename>2.png. You should only provide the first part of the filename and ButtonAdd() 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.
ButtonAdd() 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 .
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.
int OnButton(int id)
sprintf(msg,"You pressed the button %d times so far!",count);
tx=TextAdd(0,10,50,"You have not yet pressed the button!",ft);