I'd like to be able to toggle open the panel (termainl, debug, output, etc.. area) and focus on a specific custom view given an id. I know this is possible since there are focus commands for terminal debug etc but searching them up in the vscode source code just gives string references and not publicly usable functions. Any help would be appreciated. (Please don't give shortcut answers like ctrl+j, I want to do this with code)
I tried copying the format of the focus view commands above but the focus of the custom view didn't work. Seems like its not an automatic thing.
I think you want this. Every custom TreeView or WebView gets some commands added automatically by vscode. For example, my Editor Manager ViewContainer, with this view:
"views": {
"editorManager": [
{
"id": "editor-groups",
"name": "Groups",
"size": 1,
"visibility": "visible"
}
]
}
gets these commands added automatically (they can be found in the Keyboard Shortcuts, at least when the extension is activated):
editor-groups.focus
workbench.actions.treeView.editor-groups.refresh
workbench.actions.treeView.editor-groups.collapseAll
workbench.view.extension.editorManager
workbench.view.extension.editorManager.resetViewContainerLocation
You probably want the first one to focus your view in the Panel.
vscode.commands.executeCommand("editor-groups.focus");
Related
I am developing a VSCode extension and just finished adding the icon to the activity bar. What I want to do is, execute a command whenever the user clicks that icon. This is what I have tried:
Package.json
"viewsContainers": {
"activitybar": [
{
"id": "myID",
"title": "Testing",
"icon": "res/logo.svg"
}
]
},
"views": {
"myID": [
{
"id": "Explorer",
"name": "Browse contents",
"commands": "vscode-myorg.getContents"
}
]
}
However, the vscode-myorg.getContents command is not getting executed after clicking the icon. How can I achieve this?
In looking at Feature Request: Add an API event to indicate when the sidebar viewlet changes which was closed as waiting for another still open issue on getContext to be resolved. And using intellisense in package.json there is no other key besides id, title and icon. So you cannot put a command entry there for instance (I tried and nothing happened.)
There are a couple of other options that might work for you:
If your views are populated by a TreeView then you can detect when that treeViews' visibility changes:
myTree.onDidChangeVisibility(ev => {
console.log(ev); // ev.visibiltiy = true/false
})
So you can detect when the view becomes visible because the Activity Bar icon is clicked. That does work. However, this event is also triggered when the view is already opened and the user just collapses or expands that individual view. And I don't think there is really any way to distinguish between the two conditions.
If you are populating your views with a WebView there is also an onDidChangeVisibility event for that.
There is an activation event for a View becoming active:
"activationEvents": [
"onView:package-dependencies"
]
but that will only fire the first time a view is activated - and starts your extension's activate function so is probably not what you are looking for.
You have to define any new command of yours.
"commands": [
{
"command": "vscode-workat.getProblems",
"title": "Get Problems"
},
]
as well as register it in the extension.
On my quick app pages, some
content may be blocked by the app menu. For example, the sign-in entry is blocked by the app menu in the following figure.
Although the menu is configured to be movable, users do not know that they can move it.
How can I solve this problem?
The following solutions are provided to solve your problem:
Separating the menu from any content displayed
Hiding the menu
Adding a message indicating that the menu is movable
For Detail,pls kindly refer this link : What if some content is blocked by the app menu?
You can separate the menu from any content displayed by changing the value of titleBar to true in the manifest.json file.
e.g.
"display": {
"fullScreen": false,
"titleBar": "true",
"menu": false,
"menuBarData": {
"draggable": true
},
There is a good example with other solutions. Please check link
Now that VSCode has Custom Views, how can I implement one containing a simple textbox or anything but Tree?
The only example that I found is Azure Tools and it only registers tree items...
What I am after is something more like a Search panel. Is it possible to do it with VSCode Custom Views?
As of VS Code 1.29, you cannot add a search/input box to a tree view. This is tracked by this issue
You can add custom buttons to the top of a tree view using the menus -> view/title contribution point:
"menus": {
"view/title": [
{
"command": "myCommand",
"group": "navigation",
"when": "view == myTreeView.id"
}
]
LiveShare for example adds a join and start button:
You can also treat tree view items themselves as ad-hoc buttons. The Azure CosmosDB extension does this:
Please open a feature request if you are looking for more extensive customization
Like Safari app, in a macOS Swift project I would like to let users to open more than a window and possibly use tabbed browsing to switch from a window to another. The app starts with a blank window and don't need to save or open documents.
A Document Based application seems perfect to me for handle more than a window but I don't want users have to handle documents. How can I disable or hide, if possible, the Open and Save document features?
Edit: if possible, I would like to disable this popup also:
It is very simple - just remove (delete) the Open, Open Recent..., Save, Save as... menu items from the menu XIB. If you don't want a title bar, simply untick the "Title" checkbox for the window in the XIB, though that makes the window difficult to move.
If you have a title bar, to override "Untitled", you could
override var displayName: String! {
get {
return "Anything you like, even \"\""
}
set {
}
}
however that would still allow access to the save as menu through the chevron. To suppress that, you need an NSWindowDelegate Docs
window(_:shouldPopUpDocumentPathMenu:)
Asks the delegate whether the window displays the title pop-up menu in response to a Command-click or Control-click on its title.
Just add autosavesInPlace at true
I am trying to Right click on an element and then select an option "Rename" from the list. I have got "right clicking" working but can't select option from the list. Referred links 1, 2
Note 1:
1: On right click the menu options that are visible are native context menus. So, they don't appear in my DOM that I can see.
2: The App runs only in Chrome browser(not sure if it is a browser issue)
I have tried the following code:
browser.actions().mouseMove(elementVar).perform();
browser.actions().click(protractor.Button.RIGHT).click(protractor.Button.ARROW_DOWN).click(protractor.Button.ARROW_DOWN).click(protractor.Button.ARROW_DOWN).perform();
Consider, "Rename" to be the third option in the list.
Note 2:
If I am just running the app and enter 'R' from my keyboard, it selects the "Rename" option. But when I tried to run it in my test, it doesn't select the "Rename" option. See below code I tried:
browser.actions().mouseMove(elementVar).perform();
browser.actions().click(protractor.Button.ARROW_RIGHT).sendKeys('R',protractor.Key.ENTER).perform();
None of the above code works. Let me know if more information is required.
EDIT:
I am guessing the following to be happening:
once I mouse over, the script "right clicks" and after that the "tooltip" is displayed. Since the "tooltip" is displayed after "right click" I think the menu list goes to the background(the list is still visible along with the tool-tip), which is why the arrow down keys aren't working. Is this possible? If yes, how can I wait for the tooltip to be invisible and then right click?
Input: I tried to wait for tool-tip to be invisible and then right click, but still the "Arrow_down" doesn't work.
Is there a way to bring the menu list in the front once we have right clicked?
IMPORTANT:
I took a screenshot after I right clicked on the element, and the screenshot doesn't show the "menu list". Below is the code for screenshot:
browser.actions().click(protractor.Button.RIGHT).perform()
.then(function() {
browser.takeScreenshot().then(function(screenShot) {
writeScreenShot(screenShot, "image.png");
});
});
//writeScreenShot takes two variables actual screenshot data and the file name. And the screenshot is saved as "image.png"
What needs to be done?
When you send ARROW keys to the browser, you have to send them as keys instead of passing them to click() function and the ARROW_DOWN key is part of Key object and not BUTTON. Here's how -
browser.actions().mouseMove(elementVar).perform();
browser.actions().click(protractor.Button.RIGHT).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).perform();
For your second try, you should send RIGHT in the place of protractor.Button.ARROW_RIGHT to right click. When you send two actions/keys to sendKeys() function, you have to join them using chord object which combines the action of pressing two keys at a time(ex: CTRL+C for copy). But in your case i don't think its really necessary. Here's how to use it -
browser.actions().mouseMove(elementVar).perform();
browser.actions().click(protractor.Button.RIGHT).sendKeys(protractor.Key.chord("r", protractor.Key.ENTER).perform(); //Not necessary as you wont be pressing R+ENTER in your keyboard
OR
browser.actions().click(protractor.Button.RIGHT).sendKeys('R').sendKeys(protractor.Key.ENTER).perform();
Hope this helps.
use XPath to solve your problem
browser.actions().mouseMove(target).perform();
browser.actions().click(protractor.Button.RIGHT).perform();
element(by.xpath('//*[#id="context-menu"]/ul/li[1]')).click();
In your case it will be "//*[#id="context-menu"]/ul/li[3]" most probably.