ID:2148018
 
(See the best response by Kaiochao.)
Hello, i code for an SS13 server

The default behaviour when rightclicking, is to bring up a popup menu of oobjects on the tile, it's pretty cool.

However, this menu seems to be hardcoded pretty deeply, and we're having trouble working around it. Our click procs don't even register a rightclick, its intercepted before that.

What i want to do is, whenever the user holds alt and rightclicks, i want to suppress the menu and do something else instead. We've tried a few solutions to achieve this.

We've found the show_popup_menus client var, when set to zero it suppresses that rightclick menu, which is helpful.

We're trying to use that in a test, like this:

http://i.imgur.com/te2ctKd.png

This is jsut a quick proof of concept, but it doesn't work as desired. Although it does suppress the rightclick menu and allows a right click to be recorded, setting the popup menus to 1, calling parent, then setting it back to zero, doesn't seem to trigger that menu. This code just breaks the menu.

So trying this instead:

http://i.imgur.com/UgJjAOy.png

This seems to show the menu, but suppress the click. That world message never fires.

I can only guess this means the righrtclick menu is called from somewhere even lower in the code. But where? I've no idea, need help here.

One idea i had was temporarily disabling popups whenever the user presses alt, and re-enabling it when the user releases alt. Although i'm not sure from where we can take arbitrary keyboard inputs like that.

I need advice and solutions here. there's probably some way to accomplish this.

Is there perhaps some function to manually call that menu? that would work, since i have a way to reliably, but not selectively, suppress it. But i don't want the menu disabled forever
One idea i had was temporarily disabling popups whenever the user presses alt, and re-enabling it when the user releases alt. Although i'm not sure from where we can take arbitrary keyboard inputs like that.

That sounds like the best option, if you really need the built-in context menu. It should be a simple macro on Alt and Alt+Up. Either add the macro in the interface editor, or assign it in code, and call a verb such as:
// command for Alt: set-context-menu-enabled 0
// command for Alt+Up: set-context-menu-enabled 1
client/verb/set_context_menu_enabled(Enable as num)
set hidden = TRUE, instant = TRUE
if(Enable) show_popup_menus = TRUE
else show_popup_menus = FALSE
In response to Kaiochao
Can you clarify this implementation of macros?

I understand them from an end user viewpoint, i've made a few for quick use of common emotes. But i'm writing here as a coder, i can't expect all our players to create a macro in order to use this feature.
In response to NanakoAC
Best response
These are two ways to create macros (pick one).

In the interface editor:
* Open up the .dmf file included in your project. If you don't have one, you'll have to use the code-only version.
* The top third of the editor is the list of macro families. Macro families are sets of bindings that you can switch between for each Window in the skin. Open the primary macro family that's used by the default window.
* From here, it's the same as Dream Seeker's macro editor.
- * Create a new macro, set the key to Alt, and set the command. Make sure the "When released" and the "Repeat" are unchecked.
- * Create another macro, set the key to Alt, enable the "When released" option, and set the command.

In code:
// This goes in a client proc, such as /client/New():

// Create macros for Alt and Alt+Up that disable and enable the right-click menu.
var
default_macro_family = "macro"
command_pressed = "set-context-menu-enabled 1"
command_released = "set-context-menu-enabled 0"
winset(src, "AltKey", "parent=[default_macro_family]; name=Alt; command=\"[command_pressed]\"")
winset(src, "AltKeyUp", "parent=[default_macro_family]; name=Alt+Up; command=\"[command_released]\"")
Thank you kaiochao, this works pretty well, it does about 98% of what i'd hoped for and is almost perfect.

There is one niggling problem, i don't know if anything can be done about it:

While the rightclick menu is open, the macro doesn't trigger. So if someone rightclights to open the menu, then holds alt and rightclicks again, it will open the menu a second time.

Is there anything i can do about this?
In response to NanakoAC
If button-press events don't fire while a context menu is open (which seems to be the case), then there's nothing we can do. Maybe post a feature request or a bug report if you think they should fire.