Upvote 3

How to get the position of an object?

Answered Victor Conesa 13 years ago

I'm wondering if there is a way to get the relative and/or absolute position of an object (panel, rectangle, image map, etc.) in the canvas/scene.


I need to create an event able to get the value of the x or y position of the object, and set the value in a variable.


Thanks! You guys are doing a fantastic job with jim!


Alex.

Replies (16)
photo
1

I'm afraid there is no such an event to do that. But it's an interesting feature suggestion. Could you tell me why do you need it?


PD: and thanks for cheering us up! We try to do our best.

photo
1

Sure! I have a panel where I insert other items/panels (like items in a basket) and I need to know the position of one item in the list of items. It could be done by knowing the relative Y position of the dropped item in its parent panel. The "Y" position of the inserted item could be stored in a variable to operate with it later.


For example, if "Y" var value is greater than 200px, then the background of the item changes to red color.


Or if all nested items are 50px height, the Y position for the first item is 50px, the second 100 px, the third 150px, and so on. Then you can know that an item is the third, and then, change the color of its background.


This feature would allow jim to work with "ordered lists" in panels, while the "order" is a concept which a panel doesn't know about.


Any other idea on how to do that? The right question would be:


Is there a way to know the order of an object inside a vertical/horizontal aligned panel?


Thank you for your help (y saludos desde barcelona)!


Alex.

photo
1

I see. I'm afraid there is no way to know the order of an object inside a panel. Maybe you can resolve your case by storing some id into a variable each time you add something to that 'basket'. For instance if I have 4 products named a,b,c,d. Then each time I insert one of them into the basket I could add the name to a variable. The first time would be, for instance, 'b'. The second time could be 'b' concatenated to ',' and 'a' so that the variable will have 'b,a'. That way you might use the content in the variable to know, somehow, the order of the elements.

photo
1

Thanks for the advice Victor. I'll make some test, but I think it wont be easy since items can also be reordered once in the basket. If I drag&drop one item, for instance, 3 position below teh original position, there is no way for jim to know the new position of the item.


Thank you anyway! If I finally find a way to solve the issue, I will come back here to post the solution.

photo
1

Thanks alex. We have inserted that suggestion in our tracking system to take it into account in future updates.

photo
1

i have a similar issue. i either have a horizontal sequence of a set number of images, or even a wide subdivided image, that i'd like to drag-scroll left and right, snapping to each position, (preferably with animated snap-to).


if i could get and set position, i could probably handle that.


i guess i can fake it with swipe and show/hide.

photo
1

noticed something: thought it odd that i couldn't use negative position values in the Interactions' Move panel (To Position, not By Offset).


would be great if Move could be accompanied by an animation type and time! :)

photo
1

Use the action 'set focus' on the images. That 'set focus' action has an animation effect.

photo
1

I have a similar issue, where I have a vertical sequence of expandable/collapsible sections; it would be helpful to be able to move the sections dependent upon the "y" coordinates of the sections around them (so that, for example, the expansion of the top section can reposition any subsequent sections by the difference in its "expanded" height). Perhaps the capability to do this already exists...?

photo
1

You can use the 'set focus on' action to reposition the screen.

photo
1

how are you suggesting sequencing the images? putting them in table cells, for instance, fails because setting focus to a cell is not allowed

photo
1

Put them inside a dynamic panel with scroll

photo
1

works pretty well! thanks a bunch

photo
1

This is a very important feature, for my purposes. I would like to set a right-click event/interaction, and have a "context" menu appear.


This is very similar to when you right-click a folder to create a "new folder". More specifically, I would like to do this on the "tree" widget. I have a tree widget in my prototype and I want to right-click a node and then have a menu (in this case, a context menu), find the x,y coordinates of the click, move the "context menu" to the mouse x,y location, then "Show" the menu; since the tree will grow or shrink as the user open and closes the branches, the x and y coordinates become essential. This is very similar to adding a folder to the directory structure. I know this may be a lot to ask, but it is a fairly common practice. Is this (x,y position coordinates) something that can be "worked around", in the roadmap, or not considered at this time?

photo
1

We are going to start a project to add options to simulate 'resposive design' in Prototyper. The option to check the positions of the elements will be included in that project.

photo
1

This option was implemented a couple of versions ago.

Leave a Comment
 
Attach a file