Thanks for the info Matt. FWIW I found a better solution than the mouse
coordinates approach, I think, using the undocumented
mx.containers.tabclasses.Tab class:
<mx:Script>
import mx.containers.tabclasses.Tab;
function addTabDnDHandlers(evt:Object):Void {
var tab:Tab = Tab(evt.relatedNode);
trace("tab created: "+tab);
tab.addEventListener("dragEnter", tabDragEnter);
tab.addEventListener("dragExit", tabDragExit);
tab.addEventListener("dragDrop", tabDragDrop);
}
private function tabDragEnter(event:Object, format:String):Void {
event.handled = true;
this.drawFocus(true);
}
private function tabDragExit(event:Object, format:String):Void {
this.drawFocus(false);
}
private function tabDragDrop(event:Object, format:String):Void {
this.drawFocus(false);
var data = event.dragSource.dataForFormat("items")[0];
// do what's necessary with the data here; "this" refers to the
// tab that it was dropped onto
}
</mx:Script>
...
<mx:TabBar id="myTabBar" childCreated="addTabDnDHandlers(event);">
...
</mx:TabBar>
This way each individual Tab can work as a DnD listener instead of the
TabBar having to take care of determining which tab was the target. Seems
to work well.
- rdo
> I asked someone here more familiar with the TabBar and Drag and Drop.
> Here's what he said:
>
>
>
> A TabBar is just an HBox, so you can use the getChildAt() function to
> access
> the tabs. You can use the tabs 'x' and 'width' properties to determine its
> size and location. For hiliting, there is no "official" way to do this,
> but
> drawFocus(true)/drawFocus(false) should do what is desired. Of course,
> these
> methods shouldn't be called in general-purpose code since they will
> interfere with the focus manager drawing, but they should be OK to call
> within a drag and drop operation.
>
>
>
> I'm surprised that getStyle('tabWidth') is returning undefined for
> explicitly-set tabWidths. This should work.
>
>
>
> Matt
>
>
>
> -----Original Message-----
> From: Ryan Olson [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 01, 2004 11:01 AM
> To: [email protected]
> Subject: [flexcoders] Using TabBar as a drop target
>
>
>
> Hi flexcoders,
>
> I'm trying to use a TabBar as a drop target for dnd operations.
> Basically I need to drag list items to individual destination tabs on
> the TabBar. However, I'm not finding API hooks through which I can
> identify and manipulate individual tabs in the TabBar. For example, in
> the TabBar's dragEnter handler I need to determine which tab is
> currently being hovered over and somehow highlight that tab. I tried
> using the tabWidth style to determine this in a calculation using the
> mouse coordinates, but it looks like getStyle("tabWidth") is undefined
> (I guess that's a style that you can set but not get). Any suggestions
> for how to approach this? Thanks
>
> - rdo
>
>
>
>
>
>
> Yahoo! Groups Sponsor
>
>
>
> ADVERTISEMENT
>
> <http://rd.yahoo.com/SIG=129qkn1tb/M=295196.4901138.6071305.3001176/D=groups
> /S=1705007207:HM/EXP=1086199243/A=2128215/R=0/SIG=10se96mf6/*http:/companion
> .yahoo.com> click here
>
>
>
> <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=
> :HM/A=2128215/rand=921099538>
>
>
>
> _____
>
> Yahoo! Groups Links
>
> * To visit your group on the web, go to:
> http://groups.yahoo.com/group/flexcoders/
> <http://groups.yahoo.com/group/flexcoders/>
>
>
> * To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> <http://docs.yahoo.com/info/terms/> Service.
>
>