Before you do the trace, why not check if the user has clicked inside the area of the screen occupied by the panel. If he has clicked inside the panel, don't do the trace.

eg.
code:
if((mouse_pos.x < yourPanel.x) ||
(mouse_pos.x > (yourPanel.x + yourPanel.width)) ||
(mouse_pos.y < yourPanel.y) ||
(mouse_pos.y > (yourPanel.y + yourPanel.height)) )
{
// the user has clicked outside the panel, so do the trace
trace(.......);
}

Now I know .width and .height are not actually members of yourPanel, but you should know the values and can just put them in.