So I did this, first I tried triggering my function by adding an EventListener to the UIComponent where the data was being dragged to, by listening for a DragEvent.DRAG_DROP event. The problem with this is that the DragEvent.DRAG_DROP event fired before the data was added to the UIComponent where it was being dropped.
So I tried listening for a DragEvent.DRAG_COMPLETE event instead. This didn't fire when the event listener was attached to the UIComponent where the data was being dropped, but did fire when attached to the UIComponent where the data was being dragged from and also it fired after the UIComponent's dataProvider had been updated, which is what I wanted.
However, this gave me the wrong UIComponent when accessing event.target, as it gave the component the data was coming from, rather than the component the data was being dropped into (which was what I wanted). In my case though, this didn't actually matter as all I was using the UIComponent for was to check if its name contained a certain string, and the names of both my source component and destination component contain the same string.
After that I tried to change my code so that when you add an item to the filters list, it just adds that item to the XMPTextAreaMRU for filters. At the moment my code just replaces whatever is in the XMPTextAreaMRU with everything from the filters list. My thought behind changing this was so that when you have multiple files selected, you can add a new item to their XMPTextAreaMRU without deleting the multiple items data that is already there.
However, when I tried editing the XMPTextAreaMRU manually with multiple files selected, I found it automatically removes the "(multiple items)" entry, so it seems that if you add anything to a field when multiple files are selected, Bridge will automatically delete any entries that were in that field anyway.
So I reverted my changes with regards to that. Then I found that when I had multiple items with the same name in a list, I could only click on one of them. The problem was that I was adding items to the list by doing
UIComponent.dataProvider.addItem(str);
. What I should have been doing was UIComponent.dataProvider.addItem({label : str});
.I also found that when copying items from one list to another, I couldn't just do
UIComponent.dataProvider.addItem(itemFromOtherList);
, as then I would still end up with 2 of the same item, so instead I needed to do: UIComponent.dataProvider.addItem({label : itemFromOtherList.label});
After lunch I went on Animal Crossing, and also my Manfrotto 410 Junior Geared Head arrived from amazon.co.uk. It's a lot bigger than I thought it would be, if this is a Junior, I wonder how big a Senior Geared head would be?
I took some more photos of the double dandelion using the geared head, then threw the dandelion away and picked off the heads of seeding dandelions in the garden. After that I did some vacuuming, then it was dinner time.
After dinner I watched The Super Mario Bros. Super Show and The Legend Of Zelda with Mac and Lad.
With my custom XMP File Info Panel, I found that I could drag items from one list source into a different list, e.g. I could drag an item from 'FiltersList' to 'AddOnLensesUsed'. So to prevent this, I changed my DragEvent Listener to be attached to the destination list again and also listen for a DRAG_DROP event. Then in the function called by the listener I prevented the default action and added the items to the destination list manually:
private function dragDropAddItem(event:DragEvent):void
{
try{
event.preventDefault();
var itemName:String = getItemName(event);
if(event.dragInitiator.name.indexOf(itemName) != -1)
{
var stuff:Object = event.dragSource.dataForFormat('items');
var i:String;
for(i in stuff)
{
event.target.dataProvider.addItem({label : stuff[i].label});
}
}
//Update the relevant XMPTextAreaMRU so the changes will be saved
saveItems(itemName);
//FiltersList.dispatchEvent( new DragEvent("dragComplete", false, true, event.dragInitiator, event.dragSource, DragManager.COPY, false, false, false) );
}
catch(e)
{
Alert.show(e.message);
}
}
However, while this worked, the display of the list in Bridge would get messed up. The line that indicates where in the list the items will be added stays there, the list stays focused (blue outerglow) and moving the mouse up or down scrolls the list:
I tried for quite a while to get a video of this action, but the Free CamTasia software I downloaded ages ago and only installed just now doesn't seem to work. It seems like it can do everything except export the video to a normal video file. When you click on the 'publish video' options, nothing happens. I also tried a batch export, but that just crashed it. Maybe not compatible with Vista properly or sumat.
Anyway, back to my messed up list problem I think I will have to either defocus the list or otherwise change the function so it just doesn't prevent default if the source and destination list are both part of the same group.
Oh... I just looked at the Adobe doc Example: Copying data from one List control to another List control, and in the example it has
// Since you are explicitly handling the dragDrop event,
// call hideDropFeedback(event) to have the drop target
// hide the drop indicator.
// The drop indicator is created
// automatically for the list controls by the built-in
// event handler for the dragOver event.
event.currentTarget.hideDropFeedback(event);
which fixes the problem. Actually I'll have to change my function to mirror Adobe's example, as my function doesn't take into account where in the list the items were dragged.
The weather today was overcast most of the day, then brightened up later in the afternoon. It was very windy all day.
Food
Breakfast: Maple & Pecan crunch cereal; cup o' tea.
Lunch: 2x cheese on toast; sweet & crunchy salad; cherry tomatoes; clementine; caramel Rocky; cup o' tea.
Dinner: Chicken pie; gravy; potatoes; peas; sweetcorn. Pudding was Rhubarb crumble with cream. Coffee; some chocolate bunny.
No comments:
Post a Comment