Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension Developer: Custom 'when' clauses for keyboard bindings & menus #23747

Closed
warrenbuckley opened this issue Mar 31, 2017 · 1 comment
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@warrenbuckley
Copy link

I have come across the when property for KeyBindings & Menus in the Contribution points in the package.json file of my extension, but I would love to be able to based inside some logic of my extension to enable/disable showing & hiding certain menu options.

https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts

I could achieve this with a configuration but this seems wrong & a bit hacky for my situation, as I would not want the user to configure this value.

"configuration": {
    "type": "object",
    "title": "IIS Express Settings",
    "properties": {
        "iisexpress.serverRunning": {
            "type": "boolean",
            "default": false,
            "description": "This property is not to be set or used in settings.config its just used to display the correct menu items if the server is running or not"
        }
    }
}

So in my extension I could update the config value when IIS Express Server is running so that the Restart & Stop Server commands are only visible in the menu & keyboard bindings etc.

Can I suggest some form of API to allow the when property to work with some developer defined boolean that could be toggled from the extension developers codebase

@jrieken
Copy link
Member

jrieken commented Mar 31, 2017

There is an API-command which allows you set a context key. See #10471 (comment).

Closing this as dupe of #10471 which should be considered for April

@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label Mar 31, 2017
@jrieken jrieken closed this as completed Mar 31, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

2 participants