API:Hyperlink Assign

function Hyperlink_Assign( link, key )
	local _type, _data, _name = ParseHyperlink(link);
	if( _type == "item" )then
		if( key == "LBUTTON" and IsShiftKeyDown() ) then
			ChatEdit_AddItemLink( link );
		elseif( key == "LBUTTON" and IsCtrlKeyDown() )then
			ItemPreviewFrame_SetItemLink( ItemPreviewFrame, link );
		elseif( key == "LBUTTON" )then
			GameTooltipHyperLink:SetHyperLink( link );
		elseif( key == "RBUTTON" )then
			ChatFrameDropDown.hyperlinkType = _type;
			ChatFrameDropDown.link = link;
			ChatFrameDropDown._type = _type;
			ChatFrameDropDown._data = _data;
			ChatFrameDropDown._name = _name;
			ToggleDropDownMenu( ChatFrameDropDown, 1, nil, "cursor" , 0 , 0 );
		end
	elseif( _type == "skill" )then
		if( key == "LBUTTON" and IsShiftKeyDown() ) then
			ChatEdit_AddItemLink( link );
		elseif( key == "LBUTTON" )then
			GameTooltipHyperLink:SetHyperLink( link );
		end
	elseif( _type == "player" )then
		--|Hplayer:name|h[name]|h
		--|Hplayer:%s|h[%s]|h
		playername = _data;
		if( key == "LBUTTON" and IsShiftKeyDown() ) then
			if ( ChatEdit_AddItemLink( link ) )then
			
			else
				AskPlayerInfo( playername );	
			end
		elseif( key == "LBUTTON" )then
			local editbox = GetKeyboardFocus();
			if( editbox )then	
				editbox:InsertText( _name );
				return ;
			end
			if( playername ~= UnitName( "player" ) )then
				ChatFrame_SendTell( playername );
			end
		elseif( key == "RBUTTON" )then
			ChatFrameDropDown.hyperlinkType = _type;
			ChatFrameDropDown.playername = playername;
			ToggleDropDownMenu( ChatFrameDropDown, 1, nil, "cursor" , 0 , 0 );
		end
	elseif( _type == "chat" )then
		--|Hchat:公會|h[公會]|h
		if( key == "LBUTTON" )then
			ChatEditMenu_SetChatType( DEFAULT_CHAT_EDITBOX, _data );
		end
	elseif( _type == "channel" )then
	--	DEFAULT_CHAT_FRAME:AddMessage( "_data = " .. _data );
		--|Hchannel:1|h[xxx]|h
		if( key == "LBUTTON" )then
			DEFAULT_CHAT_EDITBOX.channelTarget = tonumber( _data );
			ChatEditMenu_SetChatType( DEFAULT_CHAT_EDITBOX, "CHANNEL" );
		elseif( key == "RBUTTON" )then
			ChatFrameDropDown.hyperlinkType = _type;
			ChatFrameDropDown.channelID = _data;
			ChatFrameDropDown.channelName = _name;
			ToggleDropDownMenu( ChatFrameDropDown, 1, nil, "cursor" , 0 , 0 );
		end
	elseif( _type == "npc" )then
		if( key == "LBUTTON" and IsShiftKeyDown() )then
			ChatEdit_AddItemLink( link );
		elseif( key == "LBUTTON" )then
			WorldMap_AutoMoveByNpcID( _data ); 
		elseif( key == "RBUTTON" )then
			ChatFrameDropDown.hyperlinkType = _type;
			ChatFrameDropDown.npcID = _data;
			ChatFrameDropDown.npcName = _name;
			ToggleDropDownMenu( ChatFrameDropDown, 1, nil, "cursor" , 0 , 0 );
		end
	elseif( _type == "quest" )then
		if( key == "LBUTTON" and IsShiftKeyDown() ) then
			ChatEdit_AddItemLink( link );
		elseif( key == "LBUTTON" )then
			GameTooltipHyperLink:SetHyperLink( link );
		end
	end
end