Dragging and dropping table rows in a scroll view is a little tricky

54 views
Skip to first unread message

Mike Fellows

unread,
Apr 7, 2011, 12:22:58 PM4/7/11
to Cappuccino & Objective-J
Hi,

I've got a CPTableView inside a CPScrollView with rows that can
dragged and dropped. It works really nicely including the case where
you need to drag a row to an area of the table that is not currently
visible in the scroll view. As you drag to the edge of the scroll
view it starts to automatically scroll at a certain point. But I do
find that the area near the edge where the auto scrolling starts is
quite small, and the speed of the auto scrolling is limited.

Don't get me wrong, it functions properly, but it feels very difficult
to use. You've got be be very precise with the cursor, and on some
touchpads it can be a painfull to use.

I was hoping that this would be adjustable. But I tracked down the
code that sets this area to line #264 in CPDragServer.j, namely:

insetBounds = CGRectInset(bounds, 10, 10),

The auto scrolling area is set to a 10 pixel margin just inside the
current visible area of the scroll view.

I looked through the Cocoa docs and couldn't find any settings that
seemed to control the size of this "auto scrolling on drag area" (for
lack of a better name).

So I had a couple of questions:

1. Do Cocoa apps have a similarly sized area of sensitivity and speed
of auto scrolling in apps that allow dragging and dropping of rows
(sorry I don't own a Mac to test)? If so is there any way to adjust
that?

2. Does anyone else find this behaviour in Cappuccino a little tricky
to use?


As an experiment I changed the insetBounds to use 30 pixels instead.
Dragging and dropping in my table felt much more like what I would
expect. It just felt more usable, particularly with big tables where
a lot of auto scrolling was needed to move things around.

Thanks for any help,
Mike

Klaas Pieter Annema

unread,
Apr 8, 2011, 2:15:22 AM4/8/11
to objec...@googlegroups.com
1. It depends. In a tableview for example, the inset bounds is equal to the height of the row.
2. Yes.

I've tested the behavior in a Mac application and to be honest it doesn't work very well either. It's way faster than ours, which makes it really hard to control.

We should probably play around with this behavior a lot more to see what works. I've created an issue for this.

- Klaas Pieter
--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To post to this group, send email to objec...@googlegroups.com.
To unsubscribe from this group, send email to objectivej+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/objectivej?hl=en.

Mike Fellows

unread,
Apr 8, 2011, 2:49:16 AM4/8/11
to Cappuccino & Objective-J
On Apr 7, 11:15 pm, Klaas Pieter Annema <klaaspie...@annema.me> wrote:
> 1. It depends. In a tableview for example, the inset bounds is equal to the height of the row.

I'll have to go have another look, but I don't think this is true (or
at least not entirely true). At the very least making the inset
bigger in CPDragServer makes autoscrolling in CPTableView
significantly faster.

> I've tested the behavior in a Mac application and to be honest it doesn't work very well either. It's way faster than ours, which makes it really hard to control.
>
> We should probably play around with this behavior a lot more to see what works. I've created an issue for this.

I'd agree completely with you that we should just sort this out. My
experiments with CPTableViews, dragging and autoscrolling with the
inset bounds set to 30 pixels seems to fix all of my issues. It's not
to sensitive, not too fast, just about right. I went ahead and made a
pull request for it:

https://github.com/280north/cappuccino/pull/1216

I've tested the change with tables of differing row heights on Linux
(FFox, Chrome) and Windows (FFox, Chrome, IE, Safari). They all
worked well with the setting that I propose in the pull request. But
you've made me doubt myself a bit so I'll have another look and rerun
my tests.

By the way, regarding your note in the issue, based on my inspection
of the code and my tests it _does_ speed up and slow down based on
where in the inset the cursor is. I'm guessing that with an inset of
10 there isn't enough play to notice it as much. With 30 you
certainly see it. I'd encourage you to test out my pull request to
see the results.

Thanks for the reply,
Mike

Klaas Pieter Annema

unread,
Apr 8, 2011, 7:40:48 AM4/8/11
to objec...@googlegroups.com
Thanks for the pull request, I'll try to find some time to look at it.

- Klaas Pieter
Reply all
Reply to author
Forward
0 new messages