Skip to main content
Inspiring
June 10, 2020
Question

Get object coordinates

  • June 10, 2020
  • 4 replies
  • 553 views

I am trying to get the x,y, width, and height of an element/object/shape in order to determine if the mousup event x, y coordinates is contained with in the bounds of the element. This will be for a drag and drop type event.

    This topic has been closed for replies.

    4 replies

    RodWard
    Community Expert
    Community Expert
    June 10, 2020

    You would need to use JavaScript code to achieve this.

     

    Alternatively, you could use the Infosemantics CpExtra HTML5 plugin for Captivate:

    Here is the object height: https://www.infosemantics.com.au/adobe-captivate-widgets/cpextra/help/command-variables/positioning-slide-objects#xcmndHeight

    And the object width: https://www.infosemantics.com.au/adobe-captivate-widgets/cpextra/help/command-variables/positioning-slide-objects#xcmndWidth

     

    While you are looking at these command variable help files you should probably look at the xcmndPosX and xcmndPosY variables as well.

    jpd005Author
    Inspiring
    June 10, 2020

    Thank you so much for this information and I will definitely keep it as a reference. I am aware that JavaScript is required, but I guess I was not specific in my post. (it was late and I was frustrated)

    But I have figured out away to do what I was needing to do.

    1. Make the drop target a button with no actions
    2. In JavaScript (for the slide, not the button), subscribe to the button’s mouse up event.
    3. Test for which object I am dragging.

    When the event triggers for that button, I know the mouse button was release over it. Which is all I really wanted anyway.  I got so caught with trying to do collision detection this solution was evading me for about a month.  (If someone needs code snippets for what I did, please reply.)

     

    RodWard
    Community Expert
    Community Expert
    June 11, 2020

    By all means post your code snippet here.  There are probably many users that would be interested to learn how to do this.