Draw Lines or Signature with Mouse

advanced-prototyping

#24

Did someone get this to work in Axure 9?


#25

Hi @freiand , I’m new of Axure and unfortunately I don’t know how to solve. I’m still stuck with this issue . If you find anything that can help (or another solution to get a signature) please inform me.


#26

I don’t have access to Axure at the moment but you need to add an Open Link action, choose URL then paste the code above after javascript: in the URL field. You should place the Open Link action on the OnLoad event of a widget or the page itself so it executes immediately.


#27

Hi @nkrisc,

Didn’t get it working either. Tried both with plugin and open link approach but no luck.


#28

Hi @AntonMircea,

Thanks for sharing the details.

However, the RP file still doesn’t have the interaction and may be due to it the signature is not working.

Can you please post a screenshot for interactions or guide on which elements did you show/hide or move on mouse out event?


#29

Trying this in 10 with no luck. Any tips @nkrisc?? If it’s still working for you, even in an older version could you please post a copy of your file with it in the load event?


#30

Looks like the issue was the undocumented Axure API I was relying no longer works the it did, so I’ve modified to it to not use that:

It assume that somewhere on your page there’s an Axure element you’ve named @canvas. Also I’ve not specifically used touch events so I can’t speak to how well it work on touch devices, but there’s no reason it couldn’t be modified to properly handle touch events instead of mouse events.

(() => {
var canvas = document.createElement('canvas');
var container = document.querySelector('[data-label="@canvas"]');
var containerEl = container.children[0];
canvas.width = container.clientWidth;
canvas.height = container.clientHeight;
canvas.id = 'canvas';
containerEl.append(canvas);
var ctx = document.getElementById('canvas').getContext('2d');
var mousedown = false;
canvas.addEventListener('mousedown', ev => {
mousedown = true;
ctx.beginPath();
ctx.moveTo(ev.offsetX, ev.offsetY);
});
canvas.addEventListener('mousemove', ev => {
if (mousedown) {
ctx.lineTo(ev.offsetX, ev.offsetY);
ctx.stroke();
}
});
document.body.addEventListener('mouseup', ev => {
mousedown = false;
});
function clear() {
ctx.fillStyle = '#FFF';
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
window.clear = clear;
})()​

Create a drawing canvas using javascript