How do you check the layer of a given panel?
For example, i trying to write a loop that looks at all panels in the game and tries to determine 1) was the mouse clicked over me? 2) was the mouse also clicked on a panel that has a higher layer than me?
Heres what im doing at present:
var mouse_click_x;
var mouse_click_y;
PANEL* curr_mouse_ptr;
function mouse_update_startup()
{ var mouse_click_flag;
mouse_map = mousepointer_bmap;
mouse_mode = 2;
enable_mouse = 1;
mouse_calm = 3;
while (mouse_mode>0)
{ mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
if(mouse_left&&mouse_click_flag==0)
{ mouse_click_flag = 1;
mouse_click_x = mouse_cursor.x;
mouse_click_y = mouse_cursor.y;
}
if(mouse_left==0)
{ mouse_click_flag = 0;
}
wait(1);
}
}
function mouse_left_overme(PANEL* panel)
{ if(mouse_click_x>panel.pos_x&&mouse_click_x<panel.pos_x+bmap_width(panel.bmap))
{ if(mouse_click_y>panel.pos_y&&mouse_click_y<panel.pos_y+bmap_height(panel.bmap))
{ curr_mouse_ptr = ptr_first(panel);
while(curr_mouse_ptr)
{ if(curr_mouse_ptr!=panel)
{ if(mouse_click_x>curr_mouse_ptr.pos_x&&mouse_click_x<curr_mouse_ptr.pos_x+bmap_width(curr_mouse_ptr.bmap))
{ if(mouse_click_y>curr_mouse_ptr.pos_y&&mouse_click_y<curr_mouse_ptr.pos_y+bmap_height(curr_mouse_ptr.bmap))
{ if(curr_mouse_panel.layer>panel.layer&&is(curr_mouse_panel,VISIBLE))
{ return(0);
}
}
}
}
curr_mouse_ptr = curr_mouse_ptr.link.next;
}
return(1);
}
}
return(0);
}
This all works fine except for "curr_mouse_panel.layer". This causes an engine crash. How do i find out what layer a panel is on?