Skip to content

Commit fb34338

Browse files
committed
added clearDrawing() to erase the pad.
1 parent 6257152 commit fb34338

File tree

8 files changed

+28
-5
lines changed

8 files changed

+28
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ var frame = require("ui/frame");
3131
function getDrawing(args) {
3232
// get reference to the drawing pad
3333
var pad = frame.topmost().currentPage.getViewById("drawingPad");
34-
// then access the 'drawing' property of the signaturepad;
34+
// then access the 'drawing' property (Bitmap on Android) of the signaturepad
3535
var drawingImage = pad.drawing;
36+
37+
// If you want to clear the signature/drawing...
38+
pad.clearDrawing();
3639
}
3740
exports.getDrawing = getDrawing;
3841
```

demo/app/main-page.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function padLoaded(args) {
2323
}
2424
exports.padLoaded = padLoaded;
2525

26-
2726
function getDrawing(args) {
2827
var pad = frame.topmost().currentPage.getViewById("drawingPad");
2928
var pic = pad.drawing;
@@ -33,6 +32,6 @@ exports.getDrawing = getDrawing;
3332

3433
function clearDrawing(args) {
3534
var pad = frame.topmost().currentPage.getViewById("drawingPad");
36-
pad.clear();
35+
pad.clearDrawing();
3736
}
3837
exports.clearDrawing = clearDrawing;

demo/app/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
penWidth="3" />
1919

2020
<Button text="Get Drawing" tap="getDrawing" />
21-
<!--<button text="Clear Drawing" tap="clearDrawing" />-->
21+
<button text="Clear Drawing" tap="clearDrawing" />
2222
</StackLayout>
2323
</ScrollView>
2424
</Page>

demo/app/videos/big_buck_bunny.mp4

-5.26 MB
Binary file not shown.

demo/app/videos/small.mp4

-375 KB
Binary file not shown.

signaturepad.android.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ var SignaturePad = (function (_super) {
4444
enumerable: true,
4545
configurable: true
4646
});
47+
SignaturePad.prototype.clearDrawing = function () {
48+
try {
49+
this._android.clear();
50+
}
51+
catch (ex) {
52+
console.log("Error clearing the pad: " + ex);
53+
}
54+
};
4755
return SignaturePad;
4856
})(common.SignaturePad);
4957
exports.SignaturePad = SignaturePad;

signaturepad.android.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ export class SignaturePad extends common.SignaturePad {
3434
}
3535
}
3636

37+
public clearDrawing() {
38+
try {
39+
this._android.clear();
40+
} catch (ex) {
41+
console.log("Error clearing the pad: " + ex);
42+
}
43+
}
44+
3745
}

signaturepad.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ declare module "signaturepad" {
99
/**
1010
* Represents a Signature Pad (drawing pad) component.
1111
*/
12-
export class Video extends view.View {
12+
export class SignaturePad extends view.View {
1313
public static penColorProperty: dependencyObservable.Property;
1414
public static penWidthProperty: dependencyObservable.Property;
1515

@@ -37,6 +37,11 @@ declare module "signaturepad" {
3737
* Gets or set the stroke width attribute
3838
*/
3939
penWidth: any;
40+
41+
/*
42+
* Use this to clear/erase the pad
43+
*/
44+
clearDrawing: Function;
4045
}
4146

4247
/**

0 commit comments

Comments
 (0)