Manual Drag&Drop on Panel components

Ok people I have been following this example
http://blogs.adobe.com/flexdoc/drag_and_drop/
What the goal of my application will be to have a canvas on
top of my application and one at the bottom. I will start off with
a set of dynamically generated panels in the top or bottom canvas,
doesn't really matter which. I want to be able to count how many
panels are in each canvas and get the related id and name for each
panel in each canvas.
I have set up a canvas at the top where I pretty much just
have the code from that example I linked to at the top except that
my panels are generated on the fly and their count is variable. I
am STRUGGLING to create a "two way drag and drop" between the two
canvases (moving child panel from the top canvas to the bottom
canvas and vice versa).
I have found PLENTY of two way drop and drag examples but
they all were about lists, datagrid, or tree components -
components that already come built in with "drag and drop" and "two
way drag and drop" but in my case the drag and drop is manually
created.
I am totally clueless as to the process. Can anyone point me
in the right direction? I posted in the yahoo usergroups but so far
my post has NOT been approved and it was posted like three hours
ago.
Any help is GREATLY appreciated.
Here is part of my mxml:
<mx:Canvas id="memberFilters"
width="680" height="275"
borderStyle="solid"
backgroundColor="#B6FABB"
x="10" y="10"
dragEnter="doDragEnter(event);"
dragDrop="doDragDrop(event);">
</mx:Canvas>
<mx:Canvas id="nonMemberFilters"
width="680" height="275"
borderStyle="solid"
backgroundColor="#FBB7B7"
x="10" y="325"
dragEnter="doDragEnter(event);"
dragDrop="doDragDrop(event);">
</mx:Canvas>
here is part of of my .as file:
// Drag initiator event handler for
// the title bar's mouseMove event.
private function tbMouseMoveHandler(event:MouseEvent):void
var dragInitiator:Panel=Panel(event.currentTarget);
var ds:DragSource = new DragSource();
ds.addData(event.currentTarget, 'panel');
// Update the xOff and yOff variables to show the
// current mouse location in the Panel.
xOff = event.currentTarget.mouseX;
yOff = event.currentTarget.mouseY;
// Initiate d&d.
DragManager.doDrag(dragInitiator, ds, event);
// Function called by the canvas dragEnter event; enables
dropping
private function doDragEnter(event:DragEvent):void
DragManager.acceptDragDrop(Canvas(event.target));
// Function called by the Canvas dragDrop event;
// Sets the panel's position,
// "dropping" it in its new location.
private function doDragDrop(event:DragEvent):void
// Compensate for the mouse pointer's location in the title
bar.
var tempX:int = event.currentTarget.mouseX - xOff;
event.dragInitiator.x = tempX;
var tempY:int = event.currentTarget.mouseY - yOff;
event.dragInitiator.y = tempY;
// Put the dragged panel on top of all other components.
memberFilters.setChildIndex(Panel(event.dragInitiator),
memberFilters.numChildren-1);
// Function called by the Canvas dragDrop event;
// Sets the panel's position,
// "dropping" it in its new location.
private function doDragDrop(event:DragEvent):void
// Compensate for the mouse pointer's location in the title
bar.
var tempX:int = event.currentTarget.mouseX - xOff;
event.dragInitiator.x = tempX;
var tempY:int = event.currentTarget.mouseY - yOff;
event.dragInitiator.y = tempY;
// Put the dragged panel on top of all other components.
nonMemberFilters.setChildIndex(Panel(event.dragInitiator),
nonMemberFilters.numChildren-1);
public function onAvailableFiltersResult(result:Array):void
phpData = new ArrayCollection(result);
for(x=0; x<phpData.length; x++) {
// create each new panel and add it to the parent canvas
var filterData:Panel = new Panel();
filterData.id = "id__" + phpData[x].data;
filterData.title = phpData[x].label;
filterData.addEventListener(MouseEvent.MOUSE_DOWN,
tbMouseMoveHandler);
memberFilters.addChild(filterData);
the code in the .as is my code along with the code from the
link above

Here is the updated code ...
I replaced the onAvailableFiltersResult with createPanels to
create some 5 panels. You can replace it with
onAvailableFiltersResult.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="createPanels()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.DragManager;
import mx.containers.Panel;
import mx.core.DragSource;
import mx.events.DragEvent;
// Variables used to hold the mouse pointer's location in
the title bar.
// Since the mouse pointer can be anywhere in the title bar,
you have to
// compensate for it when you drop the panel.
public var xOff:Number;
public var yOff:Number;
// Drag initiator event handler for
// the title bar's mouseMove event.
private function tbMouseMoveHandler(event:MouseEvent):void
var dragInitiator:Panel=Panel(event.currentTarget);
var ds:DragSource = new DragSource();
ds.addData(event.currentTarget, 'panel');
// Update the xOff and yOff variables to show the
// current mouse location in the Panel.
xOff = event.currentTarget.mouseX;
yOff = event.currentTarget.mouseY;
// Initiate d&d.
DragManager.doDrag(dragInitiator, ds, event);
// Function called by the canvas dragEnter event; enables
dropping
private function doDragEnter(event:DragEvent):void
DragManager.acceptDragDrop(Canvas(event.target));
// Function called by the Canvas dragDrop event;
// Sets the panel's position,
// "dropping" it in its new location.
private function doDragDrop1(event:DragEvent):void
// Compensate for the mouse pointer's location in the title
bar.
var tempX:int = event.currentTarget.mouseX - xOff;
event.dragInitiator.x = tempX;
var tempY:int = event.currentTarget.mouseY - yOff;
event.dragInitiator.y = tempY;
memberFilters.addChild(Panel(event.dragInitiator));
// Put the dragged panel on top of all other components.
memberFilters.setChildIndex(Panel(event.dragInitiator),
memberFilters.numChildren-1);
// Function called by the Canvas dragDrop event;
// Sets the panel's position,
// "dropping" it in its new location.
private function doDragDrop2(event:DragEvent):void
// Compensate for the mouse pointer's location in the title
bar.
var tempX:int = event.currentTarget.mouseX - xOff;
event.dragInitiator.x = tempX;
var tempY:int = event.currentTarget.mouseY - yOff;
event.dragInitiator.y = tempY;
nonMemberFilters.addChild(Panel(event.dragInitiator));
// Put the dragged panel on top of all other components.
nonMemberFilters.setChildIndex(Panel(event.dragInitiator),
nonMemberFilters.numChildren-1);
public function createPanels():void
for(x=0; x<5; x++) {
// create each new panel and add it to the parent canvas
var filterData:Panel = new Panel();
filterData.id = "id__" + x;
filterData.title = "Panel-" + x;
filterData.addEventListener(MouseEvent.MOUSE_DOWN,
tbMouseMoveHandler);
memberFilters.addChild(filterData);
]]>
</mx:Script>
<mx:Canvas id="memberFilters"
width="680" height="275"
borderStyle="solid"
backgroundColor="#B6FABB"
x="10" y="10"
dragEnter="doDragEnter(event);"
dragDrop="doDragDrop1(event);">
</mx:Canvas>
<mx:Canvas id="nonMemberFilters"
width="680" height="275"
borderStyle="solid"
backgroundColor="#FBB7B7"
x="10" y="325"
dragEnter="doDragEnter(event);"
dragDrop="doDragDrop2(event);">
</mx:Canvas>
</mx:Application>

Similar Messages

  • Drag Drop Dockable Panels

    Hi there all,
    Does anybody know if there is source code/widgets/extensions
    out there to
    achieve the same effect as the BBC home page.
    http://www.bbc.co.uk/
    It's really the ability to drag/drop/dock the panels and the
    fact the panel
    positions are stored (I'm presuming via a cookie).
    Would really appreciate any help at all.
    Cheers,
    @ndyB

    @ndyB wrote:
    > Hi there all,
    >
    > Does anybody know if there is source
    code/widgets/extensions out there
    > to achieve the same effect as the BBC home page.
    >
    http://www.bbc.co.uk/
    >
    > It's really the ability to drag/drop/dock the panels and
    the fact the
    > panel positions are stored (I'm presuming via a cookie).
    > Would really appreciate any help at all.
    Try this:
    http://www.webdesignermag.co.uk/tutorial_files.php?tutorial=19
    Dooza
    Posting Guidelines
    http://www.adobe.com/support/forums/guidelines.html
    How To Ask Smart Questions
    http://www.catb.org/esr/faqs/smart-questions.html

  • New 16GB iTouch - cannot manually drag/drop songs

    I just purchased a new 16GB iTouch this past wkd from the Apple store. (As background I have previously owned the 1st generation and latest iPod nanos). After reading some of the posts, I decided not to upgrade the software to v3.0.
    I connected the iTouch to my computer, and it is recognized by iTunes. I unchecked any related "automatically sync" features and made sure that "manual sync" was turned on. However, I still cannot seem to "drag and drop" songs from my Music Library to my iTouch; I also cannot "drag and drop" any of my playlists. I have not even tried to bother with my photos. Also, please note, my iTunes works just fine with both of my iPods.
    Please help!!! Am I having this problem b/c I am not upgrading the iTouch software to the new version?

    roaminggnome - thanks for your quick reply. Apologies, I should have been more specific in my post. So that my songs would not be automatically synched, I had previously checked the box under devices/my ipod/summary/manually manage music" - I also had done so for both of my old iPods.
    I already downloaded the manual and read thru a bunch of older posts and I could not find any reference to this "drag/drop" issue.

  • Unable To Manually Drag & Drop Songs To iPod

    I've just installed the latest iTunes v7.0.1.8.
    My 4th gen iPod connects fine but I can't view what songs are on it or manually 'drag' songs to it from iTunes.
    It shows up in 'Devices' and when I click on it I get a 4 tab option screen (Summary/Music/Podcasts/Contacts) - in Summary I've ticked 'Manually Manage Music', I then click on the 'Music' tab but all I get is a screen showing Sync music and a list of all my different genres. I ticked the sync music box and managed to wipe 3500 songs from my iPod!!
    I reinstalled the songs automatically but still can't view them in the Music screen, although I can play them on the iPod via my computer!!
    I'm running Windows XP
    Please help.
      Windows XP  
      Windows XP  

    I finally found a page in Apple's support pages that describes exactly this...right after I posted the question. Go figure!
    But thank you, Katrina, it definitely helped!

  • :Drag Drop From Panel to Tree

    I have two panels in a page.  I am creating a Tree control dynamically and adding to a Panel1.  I have to drag an image from panel2 to the Tree on Panel1.
    I set the Tree property to accept the drop. When I drop the image on the Tree,  the DragDropComplete Event is not executing but the DragDropComplete Event of the Panel (Which is Tree parent container)  is executing. 
    The DragEnter event on Tree is executing but the DragDropComplete not executing. 
    How can I invoke the DragDropComplete event on Tree. Pl show some pointers. I appreciate your help.

    instead of dragComplete
         use dragDrop event
    and at the end wirte event.stopImmediatePropagation
    <Tree dragEnter="treeDragEnter(event)"   dragDrop="treeDragdrop(event)" />
    protected function treeDragEnter(event:DragEvent):void
         if(event.dragSource.hasFormat('items'))
              DragManager.acceptDragDrop(DataGrid(event.currentTarget));
    protected function treeDragdrop(event:DragEvent):void
         var items:Array = event.dragSource.dataForFormat("items") as Array;
         var str:String = new String(items[0]);var cols:Array = DG.columns;
         if(cols.indexOf(str)<0) {
         event.stopImmediatePropagation();

  • Drag drop Sub Panel VI

    Has anyone done a drag from a tree control and dropped the data into another control on the front panel of a VI running within a Sub Panel container? I believe I will have to use a queue to actually communicate the data from the parent vi to the vi in the sub panel, but let me know if I am barking up the wrong tree.
    Chris
    Practical Physics, LLC
    www.practicalphysicsllc.com
    National Instruments Alliance Partner
    Certified LabVIEW Developer

    I dont quite get what you're referring to, while editing, or in a running vi? Or transfer data to a subpaneled vi?
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Drag/drop & maximize Panels within a Tile

    Hi Guys,
    I've had a look at WASI's Dashboard, and I would like to create a much simpeler version in Flex 4.
    The begin is simple: Create a mx:Tile, dump a couple of s:Panels, everything's alligned properly. Looks good.
    I'm confused in the next steps:
    How to make the Panels 'movable'? Like: Drag the first s:Panel, and drop it as last.
    How to make the Panels 'Maximizable' without pushing the other object away? I can edit the PanelSkin, ad a maximize button, but just changing size isn't enough... somehow this panel should be "lifted out" first before resizing. But how?
    Can someone give me any pointers?

    When you say Tile do you mean a tilelist ? as Tilelist allows you to drag items around.
    To Maximise over the tilelist without touching the tile arrangement one approach would be to have a canvas with 1 child panel(maxpanel) that is not displayed.
    maxpanel.top=maxpanel.left=maxpanel.right=maxpanel.bottom=0;
    on maximize a tiled panel
    maxpanel = mytilepanel;
    mymaxcanvas.addchild(mytilepanel);
    on minimize
    mymaxpanel.removeChild(maxpanel);
    well thats just off the top of my head.
    I have some old code somewhere I did to drag tiles around whilst maintaining their original index positions which was good to do a reset, so i'll see if I can find it and put it up for you.
    David.

  • Wiping my iMac clean! Time Machine or Manual drag/drop...?

    Hi all
    I've done a bit of search but nothing's too clear yet.
    I am planning to wipe clean my iMac (it's become a bit slow) but still back up all my current files.
    I've bought a passport 2tb.
    Now, if I were to use Time Machine on my entire iMac, would I still be able to select files and bring them back onto my clean harddrive, after the clean?
    OR is the only option to drag n drop everything onto my passport and go from there once I've formatted my iMac?
    For example, re-importing my iTunes library/songs. Pro Tools sessions etc.
    I basically want a fresh computer and return select files.
    Thanks!

    Use Time Machine. Drag and drop will more than likely cause permission problems with your files. With TM you can select what to exclude from the backup and you can restore individual items. Once you've reinstalled continue to use TM as your automatic backup solution.
    A complete wipe and reinstall may not be necessary. If we knew more about your problem and your system maybe someone could offer a less painful solution. Consider downloading and running EtreCheck http://www.etresoft.com/EtreCheck and posting it's report here. It's a small free utility that will tell everything about your system and possibly offer some clue to the problem.
    Also take a look at Pondini's site for answered to your Time Machine questions http://pondini.org/TM/Home.html

  • Reordering drag drop with manual application

    Here's some pseudo MXML of what I'm dealing with:
    <vbox id=1>
         <box/>
         <box/>
         <box/>
    </vbox>
    <vbox id=2>
         <box/>
    </vbox>
    I've applied manual drag event listeners to everyone and can easily drag and drop from one vbox to another. Where it goes awry is when I try to reorder the boxes. What happens is the vbox container picks up all the drag events (enter,over,etc) but none of the children do. I know a lot of the canned components like list and datagrid allow for reordering but for some reason this manual approach (which is necessary) isn't working.
    I've tried adding mouseEnabled=true on all the boxes to no avail. I've spent a day scouring forums and documentation to no avail.
    Any direction someone could point me in would be very beneficial.

    Kind of a bump, but worth adding - Ever since ActionScript 2 in Flash you've had something called a hitTest that allows you to basically do collision logic. So, if I drag one of my child <mx:Box> items around I can have a logic trap that says: 1. Which <mx:Vbox> parent container does this hitTest belong to? 2. Which child <mx:Box> does the freshly dropped <mx:Box> have a positive hitTest on. In that sense you can figure out what the user intended to do based on who he's dropping things on (or she of course).
    Whats missing from the built in FLEX Drag classes (at least that I've found so far) is the ability to do collision detection not only on the parent container but with the child elements inside  that container. Right now, it blocks ANY flavor of the drag and drop events to child objects. I'm not sure if that's bubbling, is it? Either way. I can do it the old way with hitTest collision checks but I'm sooooo close to being able to use the native DragEvents. Plus, that means I'll  have to write a class to handle data arrays being moved from one place to another which is just duplicating what's "almost perfect".
    Just point me in a direction guys, anything is better than the brick wall I'm stuck behind right  now.

  • Problem with Drag and drop in panel dashboard

    Hi
    I am having problem with drag and drop in panel dashboard.
    I will explain what i am doing.
    I am using Oracle three column template in First region i am having a table that showing all customer.
    I drag one record from my table and drop it on customer info (CIF) page on second region it is working fine.
    my CIF page has a dashboard with 6 panel box. i am showing 6 different jsff in 6 panel box.
    I put drop target in each jsff
    <af:dropTarget dropListener="#{backingBeanScope.backing_customerinformation.handleItemDrop}"
    actions="COPY">
    <af:dataFlavor flavorClass="org.apache.myfaces.trinidad.model.RowKeySet"
    discriminant="CustomerSearchDnD"/>
    </af:dropTarget>
    when i put drop target my panel boxes moves only when i drag it to another panel box header not entire part of panel box.
    if i remove the drop target then panel box move normally as the example given on: [http://adfui.us.oracle.com:7778/faces-trunk/faces/visualDesigns/dashboard.jspx?_afrLoop=2021391022520156&_afrWindowMode=0&_afrWindowId=null] but in taht case i am not able to drag and drop my data

    You must be an Oracle employee as you're referring to a component in the upcoming JDeveloper version which has yet been released to the general public. Oracle employee's are, I believe, directed to post on internal Oracle forums.
    CM.

  • Can you Cancel "acceptDragDrop()" using Manual Drag-and-Drop?

    I have an AdvancedDataGrid (ADG) with manually drag-and-drop
    functionality built in. The user can only drag-and-drop within the
    one ADG. I do this in order to validate which items can be dragged,
    and where they can be dropped. I have run into one problem,
    however. In my override of dragEnterHandler(), I call
    DragManaged.acceptDragDrop() if the user drags an item over a valid
    item. However, if they don't drop the item there, and continue to
    drag the item around the ADG, and roll over an item that is not
    valid, there's no way to cancel the drop.
    Does anyone have any suggestions?

    Thanks for the updates.
    "ericbelair" <[email protected]> wrote in
    message
    news:gealv1$dfk$[email protected]..
    > FYI, AdvancedDataGrid property "dropEnabled" must be set
    to "true" for
    > this to work.

  • HT1386 Can I manually drag and drop a playlist from an itunes account different from my own?

    Can I manually drag and drop a playlist from an itunes account other than my own?

    Yes but then all your music will be erased and replace by the new playlist.

  • How do I manually drag and drop songs from music library to iPhone 4 using iTunes 11?

    How do I manually drag and drop songs from music library to iPhone using iTunes 11?

    If you manually manage music... on iTunes 11, go to the top left corner and there will be a pull down bar. Click "show menu bar". From there, go to view, then show sidebar. Magically, it looks like the previous versions of iTunes. Took me 3 hours of trial and error and searching through forums to figure out. Tried calling Apple to have them walk me through it and they said they wouldn't help me since I don't have Apple Care. Whatever. Hope this helps!!

  • Lost drag and drop properties panel CP8

    I developed a project in Captivate 7.  It included some drag and drop interactions.  I've upgraded to CP8 as we want to be able to release the training on mobile devices.
    I have not set it up to be a responsive project at this point - I've not learned enough about how to do that.
    I can create and edit new drag and drop interactions but as soon as I save them, close the file and reopen it, they are no longer editable. The drag and drop properties panel won't show up, the D&D outlines (blue and green) disappear, the D&D option in interactions is greyed out and I cannot edit the interaction at all.  It still has the submit button in the corner and this cannot be deleted.  There doesn't seem to be a way to edit the interaction at all.
    When I go to close the file and save it, it tells me that it is a captivate 7 file and as soon as I save it, it won't open in Captivate 7 only 8.  Save as just saves it as a Captivate file.
    How can I work around this?

    Drag&Drop would not work in responsive projects anyway.
    Maybe this is due to the upgrade? And I suppose you are working in Newbie mode, where panels are controlled by Captivate? You could try in Expert mode (fourth option 'Enable...' in Preferences) because it will allow you to open the Drag&Drop panel from the Window menu.

  • How to Rearrange components using Drag Drop functionality

    Hi,
    Is it possible to re-arrange the components inside the form using drag drop functionality in RCF?
    There are 3/4 section headers in my screen, user can re-arrange them.
    But as per the RCF document it says, "Drag Drop functionality allows users to drag the value of one component and drop it on to another". It dosent say any thing about component drag-drop.

    Hi,
    there is a componentDragSource element that you use for this. However, persisting the change of location is not handled automatically. I didn't try this, but I assume that using the component drag option gives you access to the UI component itself so you can nest it in another container
    Frank
    Ps.: the drag event always givey you access to the component. This componentDragSource however shows the component when dragging, which is a slightly better indicator if you plan to re-arrange items

Maybe you are looking for