This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
sample_code:img_toggle_button [2014/11/26 09:29] stevegarman created |
sample_code:img_toggle_button [2014/11/26 09:58] stevegarman button size |
||
---|---|---|---|
Line 6: | Line 6: | ||
The images can be passed either as file-paths or as images | The images can be passed either as file-paths or as images | ||
The sample code passes one of each. | The sample code passes one of each. | ||
+ | |||
+ | The first image decides the size of the button. | ||
+ | |||
+ | In case it is not obvious, the actual toggling is done in the OnTouchDown handler. | ||
+ | |||
+ | You could move this to any of the OnTouch events but be aware that some of them (such as SetOnTouch) may fire more often than you expect. | ||
===== The code ===== | ===== The code ===== | ||
<code javascript toggle.js> | <code javascript toggle.js> | ||
Line 39: | Line 45: | ||
function CreateImageToggle(img1, | function CreateImageToggle(img1, | ||
// | // | ||
- | // | + | // |
if (typeof img1 == " | if (typeof img1 == " | ||
img1 = app.CreateImage(img1); | img1 = app.CreateImage(img1); |