ok do it this way:
store the mouse position relative to the panel, ie lets say panel is at 120,120 of the screen and the mouse is at 125,140 at the moment of the panel is clicked.
then you get the diffrence on x and y, in our cas there is 5 diffrence on x and 20 diffrence on y.
store these on the variables like y_diff and x_diff and set this vars when the panels are clicked.
then change your panel's pos accordingly like
panel.pos_x = mouse_pos.x - x_diff;
panel.pos_y = mouse_pos.y - y_diff;
i guess i explained it in a little confusing way, if you dont understand what i am talking about, i can make a small example app.
aww rei replied before me and i did not saw that. and made an example:
BMAP* dummy_bmap = "#256x256x24";
void drag_me(PANEL* panel){
var x_diff = mouse_pos.x - panel.pos_x;
var y_diff = mouse_pos.y - panel.pos_y;
while(mouse_left){
panel.pos_x = mouse_pos.x - x_diff;
panel.pos_y = mouse_pos.y - y_diff;
wait(1);
}
}
void drag_event(PANEL* panel){
if(event_type == EVENT_CLICK){
drag_me(panel);
}
}
PANEL* draggable_panel = {
bmap = dummy_bmap;
event = drag_event;
flags = SHOW;
}
void main(){
mouse_mode = 4;
vec_set(screen_color,vector(128,128,128));
}
code is standalone, it doesnt need any external images etc. just copy/paste and run.
edit2: rei also posted an example seconds before me >.<
anyway this gives you 2 examples