Label/Text field created on mouseclick

Hi All
I’m trying to make my perspective view more interactive, I want to give the users an option of creating a Label or Text field based on a mouse-click action. So I’ll have a static diagram and I want the users to just click on some part of the diagram and create a sticky note (label) through scripting on the backend. Is it possible? If not. can I get the x.y coordinate of the mouse click through a script?

Thanks, and Cheers
Sam

you can get the xy coordinate on a mouseclike action. and you could create a field with the canvas component.
If you want it to persist tho you will also have to save/pull those “sticky notes” to the databank together with their location i guess

1 Like

@victordcq , Thanks for your response, I haven’t tried it yet. I’ll let you know if it worked

it should work, if its practical and easy tho is a different story xD

1 Like

First I’ll have to find out the script for creating a canvas component and getting the xy co-ordinates on action-performed/mouse-click :'D

1 Like

Creating a component in the canvas is simply adding an object in its instances list, that should be quite straightforward.
For the x/y coordinates, they’re available in the onClick event script:

	Arguments:
		event: Events fired by the relevant mouse/touch interaction.
			clientX (int | float): The X coordinate in local coordinates.
			clientY (int | float): The Y coordinate in local coordinates.
1 Like

I knew it should be something simple and thought I’ll figure it out as I go but thanks for pointing it out

Actually there are other x/y coordinates available, I’m not sure which you should be using:

pageX (int | float): The X coordinate relative to the whole document.
pageY (int | float): The Y coordinate relative to the whole document.
screenX (int | float): The X coordinate in global (screen) coordinates.
screenY (int | float): The Y coordinate in global (screen) coordinates.
1 Like