• Droppable AvatarImage breaks
    0 replies, posted
I'm having an issue with a droppable DPanel after I attach an AvatarImage to it. After parenting an AvatarImage to a DPanel and adding it to a DIconLayout, the AvatarImage is unable to be moved, and DoClick doesn't get called on either of them. Any ideas on how I could parent an AvatarImage to a droppable DPanel and maintain its functionality? Code to reproduce below. Place the code in autorun/whatever.lua and use the console command dropbug. [lua] if SERVER then AddCSLuaFile(); else concommand.Add( "dropbug", function( pl, cmd, args ) local main = vgui.Create( "DFrame" ); main:SetSize( 400, 400 ); main:ShowCloseButton( true ); main:Center(); main.AreaOne = main:Add( "DIconLayout" ); main.AreaOne:SetPos( 10, 30 ); main.AreaOne:SetSize( 138, 74 ); main.AreaOne:SetSpaceX( 5 ); main.AreaTwo = main:Add( "DIconLayout" ); main.AreaTwo:SetPos( 10, 168 ); main.AreaTwo:SetSize( 138, 74 ); main.AreaTwo:SetSpaceX( 5 ); -- Non Avatar slot local Slot = vgui.Create( "DPanel" ); Slot:SetSize( 64, 64 ); Slot:Droppable( "slot" ); Slot.DoClick = function() print("Slot was clicked!\n") end local item = main.AreaOne:Add( Slot ); item:SetSize( 64, 64 ); -- Avatar slot local Slot = vgui.Create( "DPanel" ); Slot:SetSize( 64, 64 ); Slot:Droppable( "slot" ); Slot.Paint = function( w, h ) end Slot.Avatar = Slot:Add( "AvatarImage" ); Slot.Avatar:SetSize( 64, 64 ); Slot.Avatar:SetPos( 0, 0 ); Slot.Avatar:SetPlayer( nil, 64 ); Slot.Avatar.DoClick = function() print("Avatar was clicked!\n") end local item = main.AreaOne:Add( Slot ); item:SetSize( 64, 64 ); main.AreaOne:Receiver( "slot", function( pnl, tbl, dropped, menu, x, y ) if ( !dropped ) then return end local item = pnl:Add( tbl[1] ); item:SetSize( 64, 64 ); end ); main.AreaTwo:Receiver( "slot", function( pnl, tbl, dropped, menu, x, y ) if ( !dropped ) then return end local item = pnl:Add( tbl[1] ); item:SetSize( 64, 64 ); end ); main:MakePopup(); end ); end [/lua] [b]Edit:[/b] Fix thanks to ChewGum, combination of SetZPos and SetMouseInputEnabled solved the issue.
Sorry, you need to Log In to post a reply to this thread.