Skip to main content
Inspiring
Jun 10, 2020 12:02 AM UTC
Question

Get object coordinates

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 is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    RodWard
    Community Expert
    Community Expert
    Jun 10, 2020 1:29 AM UTC

    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.

    Translate
    jpd005Author
    Inspiring
    Jun 10, 2020 5:53 PM UTC

    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.)

     

    Translate
    RodWard
    Community Expert
    Community Expert
    Jun 11, 2020 12:44 AM UTC

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

    Translate