-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Custom menu entires, context menu entries, and action bar items #3192
Comments
+1 |
+1 |
1 similar comment
+1 |
+10086 |
Should be similar to how command palette contributions work. Tho in addition to the |
@jrieken And we need more info that the context. Example: How to let the developers know the context. And sometimes the context can`t be serialized |
@f111fei Still should be the same flow for pattern matching. Also it should be able to make condition menu from current focused area. Menu could be shown or hidden from selected text so, yeah, I think it could be the same |
Some sample from what we have with PR #7704
{
"command": "v.sayHello",
"title": "Hello World",
"icon": "./media/Preview.svg",
"context": {
"where": "editor/primary",
"when": "typescript"
}
}
{
"command": "v.sayHello",
"title": "Paul Bier",
"icon": {
"light": "./media/Preview.svg",
"dark": "./media/Preview_inverse.svg"
},
"context": [{
"where": "editor/primary",
"when": [
"typescript",
{"pattern": "**/*.svg"}
]
}, {
"where": "editor/secondary",
"when": {"pattern": "**/*.txt"}
}]
}
{
"command": "v.sayHello",
"title": "Open With Hex",
"context": {
"where": "explorer/context",
"when": "json"
}
} Plan is to start with these locations (values for Also, the resource in question will be passed to the command as argument. |
@jrieken should we maybe enforce to provide 2 icons for light and dark themes so that we do not end up with extensions that look bad in one theme? |
Also, I see for the explorer you call it |
@bpasero I see the point with two icons but effectively we cannot make sure those icons look good or aren't the same. I think with a simple path you get to going quickly and then make theme changes - it's also what we do for editor decorations. Wrt the explorer I understand we have four places: |
Ok, if we have a similar API model elsewhere already, +1 for keeping it the same.
+1 for starting with something small and opening the API later for other use cases. The only thing I worry is that we now introduce a path (e.g.
For contributing something to the explorer context menu, I think a path would look something like Not saying we should support all of this in the beginning, maybe we only start with markdown for now which ends up to be a primary action for an editor. |
I see the point. I wonder if we can sell |
Another thing I am wondering is how would you control the order of where the action should appear? E.g. would it be possible to even go further in the path we introduce to put the action into a specific group of the area (that is what Eclipse did, e.g. there was a group inside the context menu called "edit-actions" and you could point into there). No I don't think we loose something if we have alias for the first area where we open up for contributions. We just have to document clearly where such a contribution ends up. |
I think we could just make that part of the path, like Yet another new thing that came up is how to handle things like {
"command": "foo.bar",
"mouse": "cmd+left",
"when": "markdown",
"where": "editor/secondary"
} The default for |
I would probably try to simplify this to not talk about the key pressed while invoking the action but just the fact that a modifier is pressed. Also note that someone might want to trigger an action using keyboard only and in that case we should also support the modifier even though it is not a click. Finally, we currently cannot detect a modifier click if you click on an entry in the context menu. |
Another idea: we could just enrich the context that gets passed into the command with these infos (e.g. a modifier key was pressed when invoking the command). Instead of making this all declarative. |
there is some refining going on in #8059. We will differentiate between assigning UI attributes to a command (label, icons) and defining a menu. A sample:
First label, icons etc is assigned to the command The |
Want to ask something. Is this feature would include extension for source control? The Icon in sidebar only support git right now. Will this feature allow us to override it to use other source control as plugins? |
No - this is about adding menubar entries in the editor title area, the explorer context menu, and the editor context menu for command either defined an extension or VS Code. We are consuming this API with the markdown extension: https://github.com/Microsoft/vscode/blob/master/extensions/markdown/package.json#L73 |
OK, Thanks |
I'd like to add a context menu item that performs a Google search using the current selection.
However, there doesn't seem to be a way to bind to the right click or to an open context menu event.
I see several requests for features to add to the context menu... wouldn't it be easier if VS Code just made it possible for extensions to register a context menu entry?
The text was updated successfully, but these errors were encountered: