Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently January 16th, 2025, 4:06 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Mouse position
PostPosted: April 4th, 2005, 10:00 am 
Offline

Joined: November 3rd, 2004, 2:35 pm
Posts: 117
Location: Swansea, South Wales
Where exactly does the GetMousePosition function refer to?

Is it the tip of the pointer or (as I suspect from the behaviour of one or two pubs) the centre point?

_________________
Using Opus Pro 04 v4.5, Windows 2000


For this message leiafee has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 4th, 2005, 11:20 am 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi Leia,

Thank you for your enquiry.

It's definitely the tip of the pointer. Try pasting the following code into a Script Object on the page:

Code:
while (true) {
mousepos = GetMousePosition()
Debug.trace(mousepos.x + "," + mousepos.y + "\n")
wait()
}


Now preview the publication and move the mouse to the top-left corner of the publication whilst keeping an eye on the values appearing in the script output window. You should find that when these values read 0,0 the tip of the cursor arrow is positioned in the very top-left corner of the page.

Please note, however, that if you are aligning objects with the cursor position, the centre of the object will be placed at the cursor position. Therefore, if you have a 50 x 50 pixel frame aligned to the cursor position and position the cursor at the co-ordinates 0,0, only the bottom-right quarter of the frame will visible with the rest of the frame falling outside the top and left edges of the publication.

If you want the top-left corner of the object to be aligned with the cursor, you will need to factor the width and height of the object into the positioning as follows:

Code:
while (true) {
mousepos = GetMousePosition()
offsetx = Frame.GetWidth() / 2
offsety = Frame.GetHeight() / 2
Frame.SetPosition(mousepos.x + offsetx, mousepos.y + offsety)
wait()
}


I hope this helps. Please do not hesitate to contact me if you have any further queries.

Kind regards,

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 4th, 2005, 12:33 pm 
Offline

Joined: November 3rd, 2004, 2:35 pm
Posts: 117
Location: Swansea, South Wales
Hmm, that all does work fine.

Can you have a look at the attached, this is what I was trying to do when I ran into the problem.

The 'marker' should jump to the Y part of the cursor position to act as a slider but doesn't. It goes a little way below it (which is what had me wodnering if it was trying to the centre not the tip of the arrow)

Experimenting since then and it works okay if the marker is outside the frame. But why does that make a difference and how can I get it to work as expected?


You do not have the required permissions to view the files attached to this post.

_________________
Using Opus Pro 04 v4.5, Windows 2000


For this message leiafee has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 4th, 2005, 1:24 pm 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi Leia,

Thank you for your enquiry.

The positioning of framed objects was altered in SR2 to resolve a number of issues users reported in the old 2.81 version and early builds of Opus 04.

When an object is placed in a frame, the 0,0 co-ordinates become the top-left corner of its parent frame, rather than of the page, so you must factor the width and height of the frame into the positioning actions as follows:

Code:
framepos = Frame.GetPosition()
//determines the position of the frame's centre
framewidth = Frame.GetWidth()
//determines the width of the frame
frameheight = Frame.GetHeight()
//determines the height of the frame
offsetx = framepos.x - (framewidth / 2)
//subtracts half the frame width from its horizonal midpoint to give the co-ordinate of the left edge
offsety = framepos.y - (frameheight / 2)
//subtracts half the frame height from its vertical midpoint to give the co-ordinate of the top edge

while (true) {
mousepos = GetMousePosition()
Circle.SetPosition(mousepos.x - offsetx, mousepos.y - offsety)
//moves the object to the mouse position minus the top and left co-ordinates of the frame
wait()
}


I have attached an example publication to demonstrate the result.

Kind regards,


You do not have the required permissions to view the files attached to this post.

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 4th, 2005, 2:37 pm 
Offline

Joined: November 3rd, 2004, 2:35 pm
Posts: 117
Location: Swansea, South Wales
Ah, mystery solved. That would explain why I had a vague recollection of having this working at some earlier point. Pre-SR2 presumably!

Thanks.

_________________
Using Opus Pro 04 v4.5, Windows 2000


For this message leiafee has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group