ID:2655461
 
(See the best response by Ter13.)
Code:
mob {
proc {
WhatClick(control) {
world << "click";
var/list/control2 = params2list(control);
world << control2.len;

if(control2["right"]) return "right";
if(control2["left"]) return "left";
}
}
}

Problem description:
Whenever I run the "WhatClick()" proc from the Click() event, it logs that control2.len is 4 (Containing icon-x, icon-y, left/right, and screen-loc) and it returns the proper mouse button ("left" or "right").

Whenever I run the "WhatClick()" proc from the MouseDown() event, it logs that control2.len is 0 and it returns null.

This behavior is consistent across client/Click(), obj/Click(), client/MouseDown(), and obj/MouseDown().

Is there any reason for MouseDown()'s control variable to be of length 0, where Click()'s control variable is of length 4?

Example of a MouseDown() event:
client {
MouseDown(location,control,params) {
if(usr.WhatClick(control) == "left") {
if(mouse_position.IsOverMap()) {
usr.mouseDown = 1;
if(CheckGUIConflict()) Edit();
}
}
}
}


Example of a Click() event:
obj {
gui {
mle_btn {
icon_state = "melee";
Click(object,location,control,params) {
if(usr.WhatClick(control) == "left") {
usr.unitMode = "melee";
usr.RefreshUI();
}
}
}
}
}


Edit: The reason why I am using MouseDown() is because I want to track how long the user's mouse is held down. I have a corresponding MouseUp() event to set usr.mouseDown = 0;
Best response
You left out the object parameter in client.MouseDown(). That's why you aren't getting the correct result. Look at the args of your override.
In response to Ter13
Ter13 wrote:
You left out the object parameter in client.MouseDown(). That's why you aren't getting the correct result. Look at the args of your override.

I see, I had them flipped. Click() should only have location, control, and params. MouseDown() needs all 4. I read the documentation wrong.

Thanks for your help!
Click() should only have location, control, and params. MouseDown() needs all 4. I read the documentation wrong.

No. All client mouse procs require object as the first parameter.

All atom mouse procs do not. You are reading the wrong sections. Pay attention to the object that the procs belong to.
In response to Ter13
Ter13 wrote:
Click() should only have location, control, and params. MouseDown() needs all 4. I read the documentation wrong.

No. All client mouse procs require object as the first parameter.

All atom mouse procs do not. You are reading the wrong sections. Pay attention to the object that the procs belong to.

Okay, I will definitely take a harder look at the documentation on that.