ID:133680
 
A keyboard state client variable/proc would be nice, so that for example modifier keys could be picked up and used to change the action of a click or whatever.
client
Click(obj)
if(key_state["ctrl"]) mob.Attack(obj)
else if(key_state["alt"]) mob.Pick_Up(obj)
else mob.MoveTo(obj)
Hazman wrote:
A keyboard state client variable/proc would be nice, so that for example modifier keys could be picked up and used to change the action of a click or whatever.
> client
> Click(obj)
> if(key_state["ctrl"]) mob.Attack(obj)
> else if(key_state["alt"]) mob.Pick_Up(obj)
> else mob.MoveTo(obj)
>


This is already quite possible. In fact, Click() gives you a parameter named "params" to figure out what's being done with the click. So if you want to figure out if CTRL is being held down, you could do this.

client/Click(obj, location, control, params)
var/list/params_list = params2list(params)
if("ctrl" in params_list)
mob.Attack(obj)
if("alt" in params_list)
mob.Pick_Up(obj)
else
mob.MoveTo(obj)


All of this is well documented in the new DM Reference.
In response to Unknown Person
Ah, epic. I knew that there was right, middle and left click flags but I didn't know it tracked modifier keys as well. Thanks!
In response to Unknown Person
Since the topic is the closest thing I've found to my question, I'll hijack it ;)

The Click() proc only catches left clicks for me, but not right or middle ones.

Applicable Configuration:
BYOND Version: BYOND 4.0
Operating System: Windows XP

Code Snippet (if applicable) to Reproduce Problem:
turf
ground
icon = 'ground.dmi'
Click(l, c, p)
world << "[usr] clicked with parameters [p]"


Expected Results:
I'd have expected to get left, as well as right clicks reported (causing an action event)

Schnitzelnagler clicked with parameters icon-x=6;icon-y=20;left=1
AND
Schnitzelnagler clicked with parameters icon-x=6;icon-y=20;right=1

However the
Schnitzelnagler clicked with parameters icon-x=6;icon-y=20;right=1
can not be triggered.

Actual Results:
I only get to see the left clicks, most unfortunately.
I do get additional parameters if the other mouse buttons have been clicked simultaniously, yet not a simple single right click.

Schnitzelnagler clicked with parameters icon-x=6;icon-y=20;left=1
Schnitzelnagler clicked with parameters icon-x=15;icon-y=17;left=1;right=1
Schnitzelnagler clicked with parameters icon-x=15;icon-y=15;left=1;middle=1
In response to Schnitzelnagler
*slaps self and shakes head*

I'm sorry, please forget what I just said.
I found out my misstake...

I had to disable the "popup menu" first ;)

Thank you though if you had read this.

client
show_popup_menus = 0

turf
ground
icon = 'ground.dmi'
Click(l, c, p)
world << "[usr] clicked with parameters [p]"
In response to Schnitzelnagler
You should also be able to do it by going to your map object on your interface and checking the 'Send right-clicks to mouse procs' box.
In response to Hazman
Hmm, which interface are you talking about?
How do you reach that option?
It sounds like I'm missing something important ;)

Thank you for your help in advance!