REVISITED: DND DND.FEEDBACK_INSERT_BEFORE in TreeTable [message #458847] |
Fri, 22 July 2005 14:48 |
Wim Jongman Messages: 423 Registered: July 2009 |
Senior Member |
|
|
New feedback on a two year old post about DND.FEEDBACK combinations.
What I have found is that INSERT_BEFORE and
INSERT_AFTER do not mix with SELECT (3.0.2). However, i want to drop ON a
treeitem to make it a leaf of that treeitem. And also drop before or after.
What i should really want instead of this block of code is:
event.feedback = DND.FEEDBACK_ALL;
protected void doDragOver(DropTargetEvent event)
{
/*
* Start with select. Select is not allowed in combination with
* _INSERT_..
*/
event.feedback = DND.FEEDBACK_SELECT;
/*
* From here on Veronika's work:
*
* Calculate if just under or over a TreeItem to activate
..._INSERT_..
* feedbacks.
*/
if (event.item != null)
{
Rectangle rect = ((TreeItem) event.item).getBounds();
Point pt = ((TreeItem) event.item).getParent().toControl(
event.x,
event.y);
if (pt.y < rect.y + 3)
{
event.feedback = DND.FEEDBACK_INSERT_BEFORE; // insert some
debug code if you wish
}
if (pt.y > rect.y + rect.height - 3)
{
event.feedback = DND.FEEDBACK_INSERT_AFTER;
}
}
/*
* OR the found feedback with Expand and Scroll feedbacks.
*/
event.feedback |= DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
}
"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:bkmvc9$o56$1@eclipse.org...
> InsertBefore/InsertAfter is only implemented for Trees. Please provide a
> snippet showing the problem with Trees. The following works for me in
> 2.1.1
> and 3.0:
>
> DropTarget dt = new DropTarget(tree, DND.DROP_COPY | DND.DROP_MOVE);
> dt.setTransfer(new Transfer[] {tt});
> dt.addDropListener(new DropTargetAdapter() {
> public void dragOver(DropTargetEvent event) {
> if (event.item != null) {
> Rectangle rect = ((TreeItem)event.item).getBounds();
> Point pt = tree.toControl(event.x, event.y);
> if (pt.y < rect.y + 3) event.feedback =
> DND.FEEDBACK_INSERT_BEFORE;
> if (pt.y > rect.y + rect.height - 3) event.feedback =
> DND.FEEDBACK_INSERT_AFTER;
> }
> event.feedback |= DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
> }
> });
>
> "Jeremy Gale" <eclipse.10.jgale@spamgourmet.com> wrote in message
> news:bkj7ve$vde$1@eclipse.org...
>> I'd like to second this. I'm assuming that DND.FEEDBACK_INSERT_BEFORE or
>> DND.FEEDBACK_INSERT_AFTER would insert indications (black horizontal
>> markers or something?) betweent he itmes of a Tree/Table/TreeTable but
>> I've never been able to make these work - it always seems to select the
>> items instead of indicating before or after. (I've only tried on
>> Windows).
>>
>> Any feedback on how to make these work would be appreciated.
>>
>> Trevor wrote:
>> > I have a tree table as a DROP target and was trying to use Feedback
> styles
>> > of DND.FEEDBACK_INSERT_BEFORE and DND.FEEDBACK_INSERT_AFTER, but there
>> > seems to be no visible feedback with these styles in Windows or GTK.
>> >
>> > DND.FEEDBACK_SELECT works fine but doesn't quite give the correct
> visible
>> > clues.
>> >
>> > Are these implemented at all or do I have to do something special in a
>> > TreeTable.
>> >
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03088 seconds