Get element current position? - nativescript

Is there a way to get the element's current position? it's x and y. I tried getLocationOnScreen and getLocationInWindow but the result was undefined.

I think the getLocationOnScreen and getLocationInWindow should be object, getLocationOnScreen().x or .y will be OK.

Related

Why following-sibling finds an element inside the current element and not the following one?

The xpath //div[#id='search']/div/div/div[1] finds the first yellow div. I want now to find the following element on the same level (in this case it's the div).
I tried appending //following-sibling::div[1], meaning //div[#id='search']/div/div/div[1]//following-sibling::div[1], but it finds the div inside that yellow div and not the following one. Why is that?
You want to append /following-sibling::div not //following-sibling::div.
It's very rarely appropriate to use // with any axis other than the child axis, or perhaps the attribute axis. The definition of // is that it expands to /descendant-or-self::node()/, which explains why //following-sibling::div is selecting downwards.

mouse pointer to a position up in selenium

I have a requirement to move my mouse pointer based on a value in x-axis, such that tooltip will be shown. I am not sure how to do the same in selenium. I have seen the movetoelement, keysup. But i assume they are not the correct ones for my action.
Is there a way in selenium to do this.
Thanks in advance!!!!]2
You can use Action class in selenium and move to a element position. As you are aware of your x-axis, first move your pointer to that position in x axis and then in a loop call the movetoelement of action object with (0, iterating values) till you get your preferred tool tip. This can be fine tuned if you think this grid is going to appear in the center of the screen.

Keeping one Tile Constant in a Wrap Panel

Is their anyway of keeping one tile at a constant position in a wrap panel and having all the added items (currently implementing through a listbox, so listboxitems) wrap around this item.
For example, having the blue tile constant regardless of how many items, with every other tile wrapping around it.
For example:
and:
*Edit #1
I've been looking into custom panels. Maybe i could add a field that if true, would allow for the absolute positioning of an element? Still need to understand how exactly the wrappanel wraps its elements.
*Edit #2
Just realized that idea wont work either. since the attribute of whether the item should have an absolute position would depend on the item itself and so it would require another container, like a "WrapPanelItem" of some sort to define that. Ugh lol
Edit #3
I can maybe set the "Tag" attribute of the children and have a custom Wrappanel check this attribute of the child. If it equals a certain value, it wont adjust its position? But then how do i set the initial position?
Edit #4
No luck with the previous idea.
Edit #5
So i'm attempting to make the custom panel again, but i have a few questions. When items are placed in a grid, how does the arrange method place the item in the item's desired position. I've looked and couldn't find such a property, so how then does the method know where to put the item?
Solved this by making a custom version of the "VariableSizedWrapGrid" provided in Kinnara's branch of the WP7ToolKit. (https://github.com/Kinnara/WPToolkit). It didnt work initially, as it wasn't checking if the entire block fit and instead than just the first unit of the block. If anyone is running into this problem PM me and il send you my updated control :)
O, and instead of trying to wrap around one element, i overlapped the element and had the elements wrapping in the background using the VariableSizedWrapGrid. This implementation was ALOT easier than what i was trying to do.

Any way to trigger a callback function while hovering over a point in Matlab?

I am using a while loop and within that I add ginput in MATLAB to capture the positions of mouse. I check every time if the returned position is within some area so I will plot some curve on the current figure. But the problem is, by using ginput, I have to press enter before the positions are returned. Is that any way to capture the mouse event such that when the current cursor hover over some points, a callback function will be triggered? Thanks.
Since you already have a figure you're using, you could set the listening property for the figure:
set(gcf,'WindowButtonMotionFcn', #mouseMoveListener);
But now you have to create a function called 'mouseMoveListener' (if you want to name it something else, change the words after the # sign to whatever name you want, and make sure the actual event function is named that too).
Within your function mouseMoveListener you can now get the mouse coordinates:
MousePos = get(mainAxis,'CurrentPoint');
Which tells the current point of the mouse with respect to the axes coordinates. From there, you can have whatever if statement check that the position is where you want it and perform whatever tasks you want based on that information.

Z-axis window value

I can retrieve the position of window using GetWindowRect winapi function.
It should be a function also that defines the order of windows in z-axis (which window is above and which is under), but cannot find the appropriate function.
Point me to any one?
Well, seems like EnumDesktopWindows returns windows in the Z order from the top to the bottom. So no need in any special function then (which doesn't exist perhaps).
You don't get the z order directly. You are expected to call GetWindow()passing GW_HWNDNEXT or GW_HWNDPREV to walk the z order hierarchy.
Start at one of your windows and walk until you find either the other window or your walk terminates. This then tells you the relationship between the two windows.

Resources