Get view position in window - mobile

Is it possible to get the absolute position of a View in a Titanium Window? I'm trying to overlay a rectangle on an ImageView, and I need to do a bounds check to see if the rectangle is exiting the bounds of the view.(I've registered a touchmove event handler to the window, as it doesn't seem to fire the event on the ImageView itself).
Thanks in advance.

Nevermind, I solved my own problem by overlaying a normal view and checking the touchmove event on that instead. That gave me coordinates relative to the overlayed view(and the ImageView) which was what I needed.

Related

How to get the last position when drag/drop cursor mouse out canvas

In WPF, I dont still get the last position when my cursor drag/drop out of canvas.
Please tell me the solution ?
You can get the last position with MouseMouve event. If you still want to get the MousePosition even the mouse is not on the canvas anymore, then you have to subscripe the MouseMove event from the parent control/window.

WPF drag rectangle with touch

I have a WPF app with a canvas inside a ScrollViewer. On the canvas I have some rectangles that I drag along a timeline (left-right). This works fine with a mouse, but on a touch screen I get weird behavior if the canvas is wider than the main form. First, when you begin to drag the rectangle, the canvas pans until it has scrolled to the limit, then the rectangle starts to move. I doesn't do this when using a mouse.
Another strange this is that if I pan/drag the canvas (using touch) to the limit of the scrollviewer, the main form compresses by 20-50 pixels on the side opposite of the pan direction. It springs back to shape as soon as you stop dragging. What's going on here and how do I disable this?
It seems that this has to do with ManipulationBoundaryFeedback, but I don't understand exactly how...
EDIT:
So I was able to get a little further by setting the scrollviewer panningmode to PanningMode.None in the rectangle TouchDown handler and then setting it back to PanningMode.Both in the TouchUp handler. This solved the problem of the canvas panning to the limit before the rectangle would move.
Well, I finally got my app to work with touch. As I mentioned above, setting the PanningMode to None on the TouchDown event eliminated the problem with the ScrollViewer. Setting it back to Both in the TouchUp event re-enabled it. What this means is that I can't drag the rectangle past the point where the ScrollViewer would start panning, but in my case this was not a problem.
I also had some issues with the MouseLeftButtonDown event firing during the TouchMove event so I removed it during TouchDown
-= new MouseButtonEventHandler(drag_start)
and re-added it back during TouchUp to eliminate the glitchy behavior.
+= new MouseButtonEventHandler(drag_start)
Maybe this will help someone in the future...

WPF - How to detect if mouse has stopped moving

In a WPF application, how can you detect if the mouse pointer has stopped moving?
I have a canvas and there is a circle(Ellipse) inside. User can move the mouse over the circle. I want see if the mouse is moving over the circle or it has stopped moving? MouseEnter even of the Ellipse object won't help cos it would be fired even if the mouse is not stopped over the Ellipse.
Any ideas on how to achieve this?
Thanks in advance.
Regards,
Rukshan
Try to look at the ToolTipOpening event, you can use it as a marker of the mouse stopped on your element.

WinAPI mouse move notification for full desktop

In WinAPI is there a mouse move notification for the full desktop (full screen) and not for a window only?
I would like to receive mouse screen coordinates in my main window procedure.
Edit:
What I try to do is getting the coordinates from the mouse when dragging from a button in my window to outside that window.
Not as such, no. If you wanted to do something anywhere on the desktop from within your program, e.g. point somewhere or draw something anywhere, you could capture the mouse and then follow the movement until the mouse button is released. See SetCapture for this.
For an example, see this article on MSDN: Drawing Lines with the Mouse
Otherwise you can always use Windows hooks to follow mouse movements anywhere.
You can set a mouse hook to be notified about all mouse events.
You can use GetCursorPos, or GetMessagePos that contains coordinate of the last message

Silverlight Drag and Drop (without a Canvas)

I'm trying to drag and drop (slide) a Silverlight element from one part of a window to another.
I've implemented the MouseLeftButtonDown, MouseMove, and MouseLeftButtonUp event handlers on the element, but I've run into a bit of a problem.
All of the examples I've seen involve moving the element by setting the Canvas.Left and Canvas.Top properties. None of the elements I'm trying to manipulate live inside a Canvas. Is there a way to set the absolute position of the element being dragged, based on the coordinates of the mouse? Or is there a prepackaged solution to this problems somewhere that I've missed?
All panels but Canvas use some kind of constraint to position their children. Only Canvas lets you use absolute positioning. That's why I think it is the only way to implement drag and drop .
Feel free to use a Canvas on top of your existing panel. Just remember to remove the dragged element from its original parent and put it in the Canvas (or drag some kind of copy) and do the reverse on mouse up.
One way of achieving absolutely positioning an item inside any container, not only Canvas, is to use transformation instead of Left/Top properties. For instance, to set at Left=50 Top=80 you can modify the margin values through transformation.

Resources