Check 'inv_is_floating' function to know if there is a mouse item.

Code:
if ( inv_is_floating() )
{
...



The module has no function to get and clear the floating icon so I wrote one:

Code:
var inv_get_floating_icon_item_id ()
{
	if ( !inv_floating_flag  )
		return -1;
	inv_floating_flag = 0;
	Item *item = global_floating_item_ptr->item;
	global_floating_item_ptr->item = NULL;		
bmap_remove(global_floating_item_ptr->floating_item_panel->bmap);
pan_remove(global_floating_item_ptr->floating_item_panel);
);
	return item->id;
}



Code:
if ( inv_is_floating() )
{ 
   var item_id = inv_get_floating_item_id ()
   if ( item_id == SWORD_ID )
   {
      ...