mouse_panel doesnt 'work' for texts, BUT if there is a text with a higher layer
than an underlying panel, then the text will 'cover' the panel, and
mouse_panel will become NULL.

I hate 'dirty' if's, so thy this if instead...
if((temp_panel.layer > panel.layer) && (temp_panel != panel))
just on a chance the two parts of the if are getting tangled...

Or try this one, in case its temp_panel going wrong...
Code:
function sort_panels(PANEL* panel)
{
	var list_no = 0;
	var sss = 0;
	
	PANEL* temp_panel;
	
	while(list_no < total_panels)
	{
		temp_panel = ptr_for_handle(panel_list[list_no]);
		if((temp_panel!=NULL) && (panel!=NULL))
		{	if((temp_panel.layer > panel.layer) && (temp_panel != panel))
			{
				layer_sort(temp_panel,temp_panel.layer - 1);
			}
		}
		list_no += 1;
	}
	
	layer_sort(panel,total_panels);
}

But beware, this may just "hide" your real problem...
But if it does, that should help you FIND the real problem...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial