question

Patrick Cloutier avatar image
0 Likes"
Patrick Cloutier asked Patrick Cloutier edited

Is it possible to get the mouse x,y position when clicking the mouse?

I'm trying to build an interactive model in which the user would interact with the 3D view with the mouse. For example by clicking where a TaskExecuter should go next.

To do this I need to obtain the mouse x,y coordinates when I click the mouse button.

Is there a way to reference the mouse position and its button?

I tried with cursorinfo() but couldn't make it work.

Thanks,

FlexSim 24.1.0
mouseclick
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Patrick Cloutier edited

https://docs.flexsim.com/en/24.1/Reference/CodingInFlexSim/CommandReference/CommandGroups.html#clickcode

I would search for view treenode functions called similar to onClick.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Patrick Cloutier avatar image Patrick Cloutier commented ·

After much trial and error I was able to make it work with clickcode and cursorinfo.

I placed this code in a billboard text just because it continuously refreshes:

if (clickcode()==2){         // when I click left mouse button
Model.find("TaskExecuter1").gotox= cursorinfo(sv,2,1,1);   // record mouse x pos
Model.find("TaskExecuter1").gotoy= cursorinfo(sv,2,2,1);   // record mouse y pos
}

Thanks,

1 Like 1 ·