PDA

View Full Version : dragging views over views


johnhenry
11-14-2003, 05:25 AM
I'm trying retrieve and change a series of attributes on one view (and its children) when another view is dragged over it. For example, I want to know the x and y coordinates of the view being dragged over. I've seen this behavior in the example Calendar app. when events/appointments are dragged from one day to another, but haven't been able to figure out how it's done.

Any ideas?

Thanks!

Chris

antun
11-14-2003, 09:14 AM
Hi Chris

That's a really good question. You can't just define an onmouseover event handler for the view whose properties you want to retrieve, because the view that's going to be capturing the mouse events is going to be between it and the mouse (since in order to be draggable, the view that you want to drag must be clickable (clickable="true") and hence it will capture mouse events.

So how is this done in the calendar? I spent about 10 minutes looking at the code (mostly poking around, searching for familiar words, and writing debug.write statements to confirm which methods were getting called). What I found was that when the event in the calendar was getting dragged, the checkMousePosition() method (in gridsliderlayout.lzx) would get called constantly (onidle) to check where the mouse was, and find out which of the days the mouse was over. A layout is what controls how siblings are arranged relative to one another. You've probably seen <simplelayout>, right?

If you wanted to achieve the same effect, you could write your own layout that did the same thing, or you could also write a class of view that knew to check the position of the mouse when some dragging flag variable was set.

Hope this helps. If you decide to give it a try and get stuck, feel free to post some code.

-Antun