[Closed] create dialog rollout at mouse pointer position
Hello.
I want to create a rollout dialog where the mouse pointer is on the screen. And because i have two monitors, the 0 position is between the monitors. I don’t know why (at least this is what max will print as mouse coords). anyway, when i run the code, the rollout will be visible in a mirror position. I tend to keep the max application on the second screen.
Can anyone help me?
This is my example code:
clearlistener()
try(destroydialog test)catch()
mouseX = ( mouse.pos[1] as integer)
mouseY = ( mouse.pos[2] as integer)
rollout test "Test"
(
on test open do
(
print mouseX
print mouseY
)
)
createdialog test 100 100 mouseX mouseY
Thank you!
Hi,
The problem is that you don’t use the right coordinates for you needs… Here you should be using mouse.screenpos instead of mouse.pos.
mouse.pos get coordinates relative to the active viewport, while mouse.screenpos get coordinates relative to the screen.
This should work the way you want:
clearlistener()
try(destroydialog test)catch()
rollout test "Test"
(
on test open do
(
print mouse.screenpos.x
print mouse.screenpos.y
)
)
createdialog test 100 100 mouse.screenpos.x mouse.screenpos.y
Hi Dave,
Thanks for your help. Now i understand better the situation.
It’s work fine now.