LSPDFR-API
LSPDFR-API copied to clipboard
Add common menu and callout action menu with callback functions to reduce callout menu clutter
Copied from this API forum thread.
Some common issues have come up repeatedly in the LSPDFR plugin developers discord, and I think many of them could be solved with some particular additions to the LSPDFR API. Some of these are also just things I'd like to see for use in my own plugins. Anyways, I think it would be good to have a central list of feature requests, where plugin developers can discuss what they would use, and the LSPDFR developers can comment on what might be possible for future versions.
There's been some concerns recently about running out of keybindings what with all of the plugins available these days all having their own menus. I'd like to propose a couple of solutions to this.
First, a "callout actions" menu which could be created within the Callout class, and would be removed when the callout is over. The way I'd do this, although obviously I'm open to other suggestions, would be to have the following methods of the Callout class, which would modify the menu for that callout. The menu would be created during OnBeforeCalloutAccepted
, the menu would become available at OnCalloutAccepted
, and would be removed at End
.
-
uint AddMenuItem(string MenuEntryName, Action CallbackFunction)
. This would add an item to the menu. When the user clicks the menu item, it would close the menu and execute theCallbackFunction
. Perhaps figure out some way to ensure the callback function is a method of the callout class owning the menu. Theuint
returned (or maybe an LHandle or something else like that) would be a unique handle to that menu entry. -
void RemoveMenuItem(uint handle)
. Remove a menu item which had been added byAddMenuItem
. -
List<uint> GetMenuItems()
to get all menu items associated with the current callout.
These actions could either be put under a new menu with a new keybind, or could be added as a tab on the N menu which would be selected by default when you press N during an active callout. I think this approach would help with a lot of the callout-specific actions which don't need to be present all the time.
I would like to see this implemented too, since LSPDFR seems pretty stable atm I think there might be time for this: http://www.lcpdfr.com/forums/topic/70849-request-centralized-menu-api/