PnS Drag n Drop

Official support for: bluecataudio.com
RELATED
PRODUCTS

Post

Hi there ,

so, this is about "drag n drop". A sort of "drag n drop" must have been introduced to PnS in the past (according to some version history, can't remember where exactly). I can't find any detailed info and examples about this topic, so it's a bit difficult to determine if this would suit my purpose...
...which, to be honest, is a bit special.

So, when I was developing Plugins with Juce, there was this possibility to drag a UI element onto the DAW, and so feed a midi track with the content of a midi file (DranNDropContainer or so, blah,.. :-D ... can't remember how I exactly implemented it, but it worked).

Does PnS provide something similar ? It's special because it's a drag n drop to the outside world... but then it's worth asking ;-)

Thanks,
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

You can indeed find some drag and drop attributes on all KUIML widgets, as shown here:

https://www.bluecataudio.com/Vault/Skin ... ommon.html

In you example you could get the path to the MIDI file into a STRING object and load your MIDI file from there to do whatever you want with it.

To export to the DAW, you could write to a temp MIDI file, get the temp file name into a STRING and define a file path drop type so that the DAW would be able to load the MIDI file upon drop.

Post

Good morning :-)

well yes, I actually had found the drag and drop attributes, I just had no idea what to do with them...
I still haven't :-D

So, lets suppose I actually have a midi file in place that i'd like to "export" to the DAW. What I believe to understand from your answer is that I should do something like this : ?

Code: Select all

<DEFINE>
    <FILE_PATH_DROP_TYPE base_type="IMAGE" image="dragMidi.bmp" width="50" height="20" drag_operations="copy"  drag_applicative_types="??????"/>
</DEFINE>

<COLUMN>
    <ROW>
        <STRING id="ID_MIDIFILE" name="./tmpMidi.mid"/>
        <FILE_PATH_DROP_TYPE drag_source_ids="ID_MIDIFILE"/>
    </ROW>
</COLUMN>
Don't know if this is what you've meant saying "define a file path drop type" ....?

Thanks again,
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

You are actually pretty close! The only thing that is missing is indeed the applicative type. Just replace your question maks by system::filepath

Code: Select all

  ... drag_applicative_types="system::filepath"/>
I have just noticed that this type has not been documented yet (there is only system::text so far), but I think it is already available with the latest versions of Plug'n Script.

By the way you will want to make sure that the path to the MIDI file is an absolute path (relative paths will not work in most cases, as you do not know what the current path is for the host application).

Post

Hi again :-)
and sorry for bothering again...but ... yes, I am one step further but not quite there...
Let me explain.
When I do this (used absolute paths everywhere just to be sure)

Code: Select all

<COLUMN>
    <ROW>
        <STRING id="ID_MIDIFILE" default="/Users/rudi/Documents/AudioDevel/Projects/dragtest_pns/dragtest-data/test.txt" />
        <IMAGE id="ID_IM1" image="/Users/rudi/Documents/AudioDevel/Projects/dragtest_pns/dragtest-data/title.png" width="80" height="40" stretch="true" drag_operations="copy" drag_enabled="true"  drag_context="*.txt"
               drag_applicative_types="system::text" drag_source_ids="ID_MIDIFILE"/>
    </ROW>
</COLUMN>
...with "system::text" and I drag the image onto a text editor, then the STRING default value (/Users/.....) appears as text in the editor. Fine
When I use system::filepath, nothing happens (yes, the test.txt file is really on the given path).

I tried this also with a midi file
(test.mid instead of test.txt, also definitely available on the path and is a proper Midi file that I can drag into Logic from the Finder)
and dragged it into Logic. Compared to my former attempt (without defining drag_applicative_types) Logic now shows a hint "you can drop audio files here...blabla" (or so). Wasn't there before, so i reckon that Logic indeed notices that there is a drag&drop operation going on.
It just seems that the drag&drop operation has no object attached....should be a file, link to a file, path ..... but seems to be "nothing" ?

Any idea what i am missing ?
Thanks :-)
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

I am not sure what is exactly missing here, but if you try the following, it should copy the skin file to the folder where you drag it to, and it should open it in your text editor when dropped onto it:

Code: Select all

<SKIN author="Blue Cat Audio" name="Default" background_color="#000000" text_color="#ffffff" font_em_size="40" margin="20">
	<!-- Includes -->
    <STRING id="file_path_string" default="$_FILE_$"/>
    <TEXT value="Drag Me!" drag_source_ids="file_path_string" drag_applicative_types="system::filepath" background_color="#000000"/>
</SKIN>

Post

hmmmmmm..... maybe it just doesn't work on a Mac ? I am pretty shure you've tried your example by yourself, right ?

I took over your example exactly as is (then, also added a string with absolute path, just to be sure) ...and.... nope, doesnt work.
Finder and Desktop show a "no entry" sign when I drag the TEXT over it.

Might also be a Mac system setting that prevents this, but ... googled, couldn't find a hint :-/

Cheers
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

It works here both on Mac and Windows. But maybe it's not in the version that you are using. Are you on the latest preview?

Post

I was on 3.33, got 3.34 (latest preview). Tried your example with AU and Standalone versions... nope :-/
"TextEdit" shows at least a "+" sign when you drag over it but upon drop, nothing happens.
I am on OSX Ventura 13.1.
DnD is basically working, I can drag a text file from Finder to an Editor and it actually shows up.
Any more thoughts ? :-D
Thanks.
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

DukeRoodee wrote: Sun Mar 12, 2023 11:25 am I was on 3.33, got 3.34 (latest preview). Tried your example with AU and Standalone versions... nope :-/
"TextEdit" shows at least a "+" sign when you drag over it but upon drop, nothing happens.
I am on OSX Ventura 13.1.
DnD is basically working, I can drag a text file from Finder to an Editor and it actually shows up.
Any more thoughts ? :-D
Thanks.
I'll have to double check if this version is supposed to work, but that's surprising. Have you tried to drop it onto the Finder? (all text editors do not behave equally regarding file path dropping).

BTW you may want to add drag_operations="copy" to my example, as it will otherwise try to move the file.

Post

I did a bit of investigation ... as far as I could get back. Couldn't download a 2.7 Version (the one where DnD has been introduced, right?) because there were only a 2.0 and 2.1 versions on the "previous version" page.
Starting from V3:
3.1: The GUI was somehow corrupted, couldn't load a preset.
3.2. was good again, but DnD to external apps not working at all.
3.3.: DnD of file to desktop/finder shows at least a "no entry" sign (drop not working),
DnD of plain text to editor (system::text) works fine.
DnD of text file to editor shows no sign of live (exept the gui symbol hovering over the editor).
DnD of .mid to Logic: shows at least this "drop audio files here" on Logic, but drop does nothing
3.34 : I stated before that in this version DnD of text file to text editor shows the gui symbol and a "+" sign, but that is only with the Mac TextEditor (i guess its the same with 3.3, didnt check that before). With SublimeText ... see 3.3, so I'd say no change from 3.3 to 3.34.

This is more or less what it looks like to me.
Would be really cool if we could find and fix the problem as this is the last bit missing for my little project. In the meanwhile I've managed to make "internal" DnD (from widget to widget) working, managed to create a .mid file upon drag start ... so, I'd be really grateful :-)

oh, btw: drag_operations="copy" didn't change anything at this stage. I think this will have an effect once I can actually drop a file onto an external app.

Thanks & Cheers
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

Hi Rudi,

sorry for the delay, it took time to double check this in details. It appears that there is indeed a bug on Mac regarding drag and drop with system::filepath. It has been fixed already (that's why it works here), but the fix hasn't made it to the preview yet. That's what happens when using undocumented features which have not been tested extensively yet, my bad! :-). I'll let you know when a new preview is available. It should not take too long.

Post

Great, thanks a lot for your support ! :-)
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

The hell, I've just been asked something in my plugins that implies drag and drop and find this discussion from... Yesterday 😂
Following then, as I'm a mac user as well 😊
Never attribute to malice that which is adequately explained by stupidity.

Post

Hi again,

sorry, I am back :-D ...there appeared some issues with the handling of drag sources. Don't know if these are bugs or if my implementation is just crap...
Difficult to explain. I've made two screen videos of it, so you can see what I am talking about.

Videos:
Video1:
Video2:

Sources:
https://bitbucket.org/pulpoaudiodev/dra ... est1.kuiml
https://bitbucket.org/pulpoaudiodev/dra ... est2.kuiml

(In the videos you'll see the mouse click shown with a circle around the pointer.)

Issue 1 / Video 1:
The red widgets are drag sources ("Source chords"), the blueish ones at the bottom (those showing the "--"s) are drop tagets.

The first three drag operations are when I click centered on a drag source and drag it onto a target. Works fine. You'll see the "C" at the top of the target widget (means that I've taken the chord from "C" source chords).
(Video: 00:00 to 00:10)
The fourth and fifth drag operations are when I click a drag source near its top or bottom edge. It'll not appear as if it would be dragging. But when I cross another drag source as I am moving the mouse (still holding the mouse button), it'll "catch" the second drag source and drag this one onto the target. On the target widget there appears a "G" on top, which means i've taken the chord from "G" source chords.
(Video: 00:15 to end)

The point is that with drag operations 4 and 5 I've actually initiated dragging on a "C" drag source, even if near the edge... and far, far away from any "G" drag source. I didn't click on any of those...

The source widgets are defined like this:

Code: Select all

<WIDGET id="$id$_WIDGET" width="$width$" height="$height$" layout_type="column" drag_source_ids="$id$_CHORD" drag_applicative_types="test" background_color="#800000">   
:
    <PARAM_TEXT param_id="$id$_DEGREE" font_size="20" height="100%"/>
:
</WIDGET> 
where height=40 (points). I would expect that the entire widget is the drag source, but it seems that not near the borders. And then, this not processed mouse click is somehow kept for later. As if saying "let's see what other element we can apply the mouse click to" :-D


In the real plugin that I am working on, the drag sources are only something like 15 points high with a 10 point font PARAM_TEXT, so it's already difficult to hit them centered. Besides, it is somehow misleading that I finally would drag an object that I've not originally clicked on.


Issue 2 / Video 2:

This is even more difficult to explain.
Here, we have similar drag sources.
For these, inside the parent drag source widget I've declared a child layer_stack widget containing two child widgets $id$_CBOX_UP and $id$_CBOX_DN, so that I can toggle "on/off" using a toggle switch:

Code: Select all

<WIDGET id="$id$_WIDGET" width="$width$" height="$height$" layout_type="column" drag_source_ids="$id$_CHORD" drag_applicative_types="test" background_color="#800000">   
:
	<WIDGET id="$id$_SWITCHWIDGET" layout_type="layer_stack" width="$width$" height="40" >
	  <PARAM id="$id$_mouseDown" name="$id$_mouseDown" type="boolean" default="false" exposed="true"/>
	  <INVISIBLE_PARAM_TOGGLE_SWITCH param_id="$id$_mouseDown" width="100%" height="40" cursor="system::hand"/>
	  <ACTION_TRIGGER event_ids="$id$_mouseDown.value_changed" script="$id$_mouseClickDown();" requires=""/>
	  <WIDGET id="$id$_CBOX_UP" width="98%" height="40" background_color="#004000" layout_type="column" visible="true">
	      <PARAM_TEXT param_id="$id$_CHORD" font_height="20"/>
	  </WIDGET>
	  <WIDGET id="$id$_CBOX_DN" width="98%" height="40" background_color="#00A000" layout_type="column" visible="false">
	      <PARAM_TEXT param_id="$id$_CHORD" font_height="20"/>
	  </WIDGET>
	</WIDGET>
:
:
    <SCRIPT requires="$id$_CBOX_UP.visible;$id$_CBOX_DN.visible;" script="
      void $id$_mouseClickDown()
      {
        if( $id$_mouseDown == 0) {
            $id$_CBOX_UP.visible=true;
            $id$_CBOX_DN.visible=false;
        } else {
            $id$_CBOX_UP.visible=false;
            $id$_CBOX_DN.visible=true;
        }
      }                    
    " /> 
 </WIDGET>
So, when i click on the element it'll show in light green, when I release the mouse button it'll show in dark green. (video: 00:00 to 00:02) Works fine so far.

But... remember that the parent widget containing all this is a drag source. This issue does NOT happen with non-drag-sources.
When I try to drag this object, it'll obviously first switch to light green ($id$_mousedown==true). I then drag it to some place on the GUI, release the mouse button, and it'll "jump back" (still light green) and then show in dark green again (00:05 to 00:08) (back to dark green sometimes only when I move the mouse again: 00:12 to 00:16).
When I then move the mouse pointer onto the previously dragged element, it'll switch to light green without mouse click. When I move the mouse pointer outside the borders of this element, it'll become dark green again (00:18 to 00:22). As if the element keeps the information "i've been clicked" and fires the $id$_mouseDown.value_changed action everytime that the mouse enters/leaves its borders.

I can then click on the element, release the mouse button immediately, and it'll show in dark green ... and also show in dark green when i hover over it, means that this way it finally received and processed the mouseButtonUp (00:23 to 00:27).


Here again, you can see the behaviour of dragging from near the borders of the element.
A simple click near the borders switches colours, which is good (00:30 to 00:34).
A drag start from near the borders doesn't initiate dragging, only from center (00:35 to 00:45).

Well, sorry for this novel, just trying to explain...
Is there someting I can do about this ?

Thanks a lot in advance
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post Reply

Return to “Blue Cat Audio”