possible to drag into a composite view/scrollview?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

possible to drag into a composite view/scrollview?

ddw_music
w = Window(\x, Rect(5, 100, 200, 150)).front;
z = ScrollView(w, Rect(5, 5, 190, 140)).background_(Color.blue(alpha: 0.2));
z.receiveDragHandler = { "got it".postln };
z.canReceiveDragHandler = true;

But if I drag something into the blue area, nothing happens.

Do I have to work around it by putting a dragsink underneath the scrollview?

(The idea is that dragging an object into the empty area should make the controller add new views into the scrollview.)
hjh


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: possible to drag into a composite view/scrollview?

ddw_music
DragSink underneath doesn't work... the scrollview swallows the drag.

How do I make a gui to do this ("... dragging an object into the empty area should make the controller add new views into the scrollview")?


On Oct 4, 2009, at 12:32 PM, James Harkins wrote:

w = Window(\x, Rect(5, 100, 200, 150)).front;
z = ScrollView(w, Rect(5, 5, 190, 140)).background_(Color.blue(alpha: 0.2));
z.receiveDragHandler = { "got it".postln };
z.canReceiveDragHandler = true;

But if I drag something into the blue area, nothing happens.

Do I have to work around it by putting a dragsink underneath the scrollview?


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

müllmusik
Administrator
Scrollviews are topviews. Topviews don't receive drags.

Not sure what's best to suggest if adding a dragsink to the scrollview doesn't meet your needs.

S.

On 4 Oct 2009, at 17:37, James Harkins wrote:

DragSink underneath doesn't work... the scrollview swallows the drag.

How do I make a gui to do this ("... dragging an object into the empty area should make the controller add new views into the scrollview")?


On Oct 4, 2009, at 12:32 PM, James Harkins wrote:

w = Window(\x, Rect(5, 100, 200, 150)).front;
z = ScrollView(w, Rect(5, 5, 190, 140)).background_(Color.blue(alpha: 0.2));
z.receiveDragHandler = { "got it".postln };
z.canReceiveDragHandler = true;

But if I drag something into the blue area, nothing happens.

Do I have to work around it by putting a dragsink underneath the scrollview?


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

ddw_music
On Oct 4, 2009, at 1:40 PM, Scott Wilson wrote:

Scrollviews are topviews. Topviews don't receive drags.

It must be more generally that composite views don't receive drags. If I replace ScrollVIew with CompositeView, same problem.

In cocoa, it seems to work to put the dragsink on top of the scrollview/compositeview, but then in swing, buttons/sliders etc. in the compositeview don't respond.

Seems like I'm screwed, huh? :)
hjh


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

müllmusik
Administrator

On 4 Oct 2009, at 20:02, James Harkins wrote:

> On Oct 4, 2009, at 1:40 PM, Scott Wilson wrote:
>
>> Scrollviews are topviews. Topviews don't receive drags.
>
> It must be more generally that composite views don't receive drags.  
> If I replace ScrollVIew with CompositeView, same problem.
>
> In cocoa, it seems to work to put the dragsink on top of the  
> scrollview/compositeview, but then in swing, buttons/sliders etc. in  
> the compositeview don't respond.
>
> Seems like I'm screwed, huh? :)

Do composite views in SwingOsc support dragging? You could just add  
that if it doesn't cause any problems. It doesn't seem unreasonable to  
me.

S.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

ddw_music
On Oct 4, 2009, at 3:41 PM, Scott Wilson wrote:

Do composite views in SwingOsc support dragging? You could just add that if it doesn't cause any problems. It doesn't seem unreasonable to me.

Yes, they do (in swing)!

Not sure where to add it for cocoa. I tried doing this but it has no effect.

My understanding of Cocoa and Objective-C is not very good, I'm afraid.
hjh


dewdrops-computer-2:~/Applications/sc-test dewdrop$ svn diff Headers/app/SCView.h Source/app/SCView.M 
Index: Headers/app/SCView.h
===================================================================
--- Headers/app/SCView.h        (revision 9308)
+++ Headers/app/SCView.h        (working copy)
@@ -222,6 +222,9 @@
        SCCompositeView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds); 
        virtual ~SCCompositeView();
 
+       virtual bool canReceiveDrag();
+       virtual void receiveDrag();
+
        virtual void setBounds(SCRect inBounds);
 protected:
 };
Index: Source/app/SCView.M
===================================================================
--- Source/app/SCView.M (revision 9308)
+++ Source/app/SCView.M (working copy)
@@ -1266,6 +1266,18 @@
 {
 }
 
+bool SCCompositeView::canReceiveDrag()
+{
+    PyrSlot result;
+    sendMessage(s_canReceiveDrag, 0, 0, &result);
+    return IsTrue(&result);
+}
+
+void SCCompositeView::receiveDrag()
+{
+    sendMessage(s_receiveDrag, 0, 0, 0);
+}
+
 void SCCompositeView::setBounds(SCRect inBounds)
 {
     SCView *child = mChildren;


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

ddw_music
In reply to this post by ddw_music
On Oct 4, 2009, at 3:02 PM, James Harkins wrote:

It must be more generally that composite views don't receive drags. If I replace ScrollVIew with CompositeView, same problem.

In cocoa, it seems to work to put the dragsink on top of the scrollview/compositeview, but then in swing, buttons/sliders etc. in the compositeview don't respond.

For posterity's sake -- once I figured out that I could get the desired behavior using slightly different arrangements of GUI widgets for cocoa vs. swing, then it was pretty easy to dispatch to a different function depending on the current GUI kit ID. It's a small-scale version of the Factory design pattern, called by:

~viewFactories[GUI.current.id].();

hjh

~viewFactories = (

// cocoa likes this:
// ScrollView with DragSink overlaid on it
// views placed in the scrollview are active even with dragsink over the container
cocoa: {
~leftScroll = ScrollView(~viewParent, Rect(~margin, ~margin,
~leftWidth, ~windowHeight));
~slotParent = ~leftScroll;
~dragSink = DragSink(~leftScroll, Rect(0, 0, ~leftWidth, ~windowHeight))
.background_(Color.clear)
.receiveDragHandler_(e { |view, x, y|
~slotPanelReceiveDrag.();
})
.canReceiveDragHandler_(e { |view, x, y|
~isValidPanelDrag.();
});
},

// swing likes this:
// ScrollView with CompositeView inside
// in swing, composite views can receive drags
swing: {
~leftScroll = ScrollView(~viewParent, Rect(~margin, ~margin,
~leftWidth, ~windowHeight));
~dragSink = CompositeView(~leftScroll, Rect(0, 0,
~leftWidth, ~windowHeight))
.background_(Color.clear)
.receiveDragHandler_(e { |view, x, y|
~slotPanelReceiveDrag.();
})
.canReceiveDragHandler_(e { |view, x, y|
~isValidPanelDrag.();
});
~slotParent = ~dragSink;
}
);



: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

müllmusik
Administrator
In reply to this post by ddw_music
If you tested this with a topview or scrollview you may be running into the issue that topviews handle dragging specially and only accept them in construction mode.

S.

On 4 Oct 2009, at 22:50, James Harkins wrote:

On Oct 4, 2009, at 3:41 PM, Scott Wilson wrote:

Do composite views in SwingOsc support dragging? You could just add that if it doesn't cause any problems. It doesn't seem unreasonable to me.

Yes, they do (in swing)!

Not sure where to add it for cocoa. I tried doing this but it has no effect.

My understanding of Cocoa and Objective-C is not very good, I'm afraid.
hjh


dewdrops-computer-2:~/Applications/sc-test dewdrop$ svn diff Headers/app/SCView.h Source/app/SCView.M 
Index: Headers/app/SCView.h
===================================================================
--- Headers/app/SCView.h        (revision 9308)
+++ Headers/app/SCView.h        (working copy)
@@ -222,6 +222,9 @@
        SCCompositeView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds); 
        virtual ~SCCompositeView();
 
+       virtual bool canReceiveDrag();
+       virtual void receiveDrag();
+
        virtual void setBounds(SCRect inBounds);
 protected:
 };
Index: Source/app/SCView.M
===================================================================
--- Source/app/SCView.M (revision 9308)
+++ Source/app/SCView.M (working copy)
@@ -1266,6 +1266,18 @@
 {
 }
 
+bool SCCompositeView::canReceiveDrag()
+{
+    PyrSlot result;
+    sendMessage(s_canReceiveDrag, 0, 0, &result);
+    return IsTrue(&result);
+}
+
+void SCCompositeView::receiveDrag()
+{
+    sendMessage(s_receiveDrag, 0, 0, 0);
+}
+
 void SCCompositeView::setBounds(SCRect inBounds)
 {
     SCView *child = mChildren;


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

ddw_music
On Oct 5, 2009, at 2:58 AM, Scott Wilson wrote:

If you tested this with a topview or scrollview you may be running into the issue that topviews handle dragging specially and only accept them in construction mode.

No, I tested with a (SC)CompositeView.
hjh


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: possible to drag into a composite view/scrollview?

magicwindow
This post was updated on .
Sorry to revive a dead thread but i've recently encountered the same problem and am hoping there have been some updates or work arounds?

I'm attempting to drag from a ListView onto a compositeview and nothing seems to be happening. I've even added a DragSink to the view and it still doesnt seem to be responding.

Here's some code, to demonstrate:

(
(
~dragWindow = Window.new("Drag Box", Rect(750,50,110,110))
.front
.alwaysOnTop_(true);

~dragWindow.view.decorator_(FlowLayout(~dragWindow.bounds, 10@10, 10@10));

~box = CompositeView(~dragWindow, 90@90)
        .background_(Color.new(0,0,0,0.25));
~drag = DragSink(~box, Rect(0, 30, 90, 30)).align_(\center);
        ~drag.string = "Drag Here";
        ~drag.background_(Color.clear);
        ~drag.canReceiveDragHandler = { View.currentDrag.isKindOf(Integer) };
    ~drag.receiveDragHandler = { arg view;
        view.object = View.currentDrag;
        view.string = View.currentDrag.asString;
        };

       
);
(
~listViewWindow = Window.new("List View", Rect(950,50,110,110))
.front
.alwaysOnTop_(true);

~listArray = [1, 2, 3];

~listView = ListView.new(~listViewWindow, Rect(0,0,110,110))
.items_(~listArray)
.beginDragAction_({ arg view, x, y;
                view.item.postln;
                });
)
)


I'm attempting to change the string of the DropSink into the items name which was dragged from the ListView. Any Help/Tips?
Loading...