when creating buttons that overlap using pan_setbutton, clicking will activate the first one created but the engine will render the second button created on top.
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>

///////////////////////////////

var var_id;

void pnl_test(var id, PANEL* p){
	
	var_id = id;
	beep();
}

void main(){
	
	wait(1);
	
	PANEL* pnl = pan_create("", 1);
	
	pnl.bmap = bmap_createblack(200, 200, 32);
	bmap_fill(pnl.bmap, COLOR_RED, 100);
	
	set(pnl, SHOW);
	
	BMAP* bmp_bg = bmap_createblack(50, 200, 32);
	bmap_fill(bmp_bg, COLOR_GREEN, 100);
	
	pan_setbutton(pnl, 0, 1, 0, 0, bmp_bg, bmp_bg, bmp_bg, bmp_bg, pnl_test, NULL, NULL);
	
	BMAP* bmp_fg = bmap_createblack(200, 50, 32);
	bmap_fill(bmp_fg, COLOR_BLUE, 100);
	
	pan_setbutton(pnl, 0, 1, 0, 0, bmp_fg, bmp_fg, bmp_fg, bmp_fg, pnl_test, NULL, NULL);
	
	mouse_mode = 4;
	
	while(1){
		
		DEBUG_VAR(var_id, 240);
		wait(1);
	}
}

it's possible to use multiple panels to overcome this but not exactly practiable.

Cheers!
MrGuest