Is it possible to add custom command shortcuts in vscode? - visual-studio-code

I'm curious about the vscode function,
is it possible to add custom command shortcut by any idea including extensions and so on?
For example, I want to put these codes with simple keyboard action like 'Ctrl+Shift+1'.
if (canvas.getContext){
let ctx = canvas.getContext("2d");
//console.log("canvas supported!");
}
else {
//console.log("canvas unsupported.");
}
and when I put 'Ctrl+Shift+1', the code that I saved past appears and able to use it.
If you know the answer, please spare your time.
Thanks a lot in advance.

Related

deleteItem PageBreakItem in google forms via apps script

I want to use deleteItem in apps script to delete an item from a form.
(I want to use this to clear the form and edit it).
Now, the code I wrote works fine for any item except the PageBreakItem.
I have tried it and as soon as there are PageBreakItems that I want to delete I get a "Failed to edit form" message. The code is here:
function generateOrderForm() {
var orderForm = FormApp.openById('....myformID.....');
// Clears all items after the 10th item.
while(orderForm.getItems().length > 10){
orderForm.deleteItem(10);
}
}
Is this a known issue and if yes is there a solution?
Is there an other way to clear a form or a workaround for what I want?
Thanks for your help!
I got the same question as you met. Your "PageBreakItem" is linked by other questions or other pages. Try to remove the link and run the script again.

LWUIT menuBar refreshTheme not working?

I'd like to dynamically change the text of a Command depending on some state, so normally I went to Google and LWUIT blogs said that using refreshTheme() on MenuBar should do the trick.
So I used the following code, but it sadly didn't work
if (isPlaying) {
playButton.setCommandName("Pause");
}else{
playButton.setCommandName("Play");
}
this.getMenuBar().refreshTheme();
Is there something wrong with my code? Or did I misunderstand something?
It won't refresh. The text of the button is set when the command is placed so you can't do that.
You will need to use removeCommand(cmd) followed by addCommand(newCmd).
Furthermore, refreshTheme() has absolutely nothing to do with anything.

How to programmatically change help contents in Eclipse?

I have an eclipse plugin and I would like to programmatically disable help content TOC's based on a variable I define. In a nut shell, I want to prevent some help docs from showing up in the help contents if a specific type of user is accessing the plugin.
Preferably I would like to do this in the ApplicationWorkbenchAdvisor somewhere.
One thought would be to modify the "primary" value to be false if the variable were set.
Not sure if it would work, but try using the org.eclipse.ui.activities extension point. The tutorial from Vogella tells it is possible to hide only UI elements like wizards, views and so on, but it is from 2009.. Not sure if hiding TOC is now possible. If you try it out, would be nice to give a feedback ;)

Dragging and dropping something onto an xna window?

I have an XNA4 wndow set up and was wondering if I could get it to accept drag+drop actions, what I envision is someone grabs a jpeg and drags it into the window, upon release of the mouse an event is fired off with a string pointing to the jpeg.
Is this doable and if so how?
First, here is a link to a tutorial on doing this with a windows form:
http://support.microsoft.com/kb/307966
and here is a link to a post about doing just this (answer is past a few posts saying that it's impossible):
http://forums.create.msdn.com/forums/p/4020/20419.aspx
finally here is some code for ease of access (you need a reference to the System.Windows.Forms namespace):
protected override void Initialize()
{
Form gameForm = (Form)Form.FromHandle(Window.Handle);
gameForm.AllowDrop = true;
gameForm.DragEnter += new DragEventHandler(gameForm_DragEnter);
gameForm.DragDrop += new DragEventHandler(gameForm_DragDrop);
}
Also, it seems it's possible to run a game inside a Form control as of XNA 2
While I recognise that this is many years too late here is a direct link to a working demo.
The SLN might not want to autoload but you can just drop it into VS2013 and it will update it. I was getting a "licencing" popup when I tried to just run the SLN.
Hope this helps anyone who might still be working on this.
http://geekswithblogs.net/mikebmcl/archive/2011/03/27/drag-and-drop-in-a-windows-xna-game.aspx

Faking a GTK_RESPONSE_OK in a GTK dialog

I want to have a gtk_file_chooser_dialog that does not browse into a folder if it has a specific name. For this I hooked up my dialog with a callback when a current-folder-changed signal is emitted. In the callback function I successfully detect if the selected folder has the specific name. However, I can't figure out how to tell the dialog to close itself and return a specific response code (e.g. GTK_RESPONSE_OK).
I have unsuccessfully tried (among other things):
g_signal_emit_by_name(G_OBJECT(my_dialog), "response", GTK_RESPONSE_OK);
Has anyone a better idea ? I would appreciate any pointers into the right direction..
cheers
You're trying too hard. Just use:
gtk_dialog_response(GTK_DIALOG(my_dialog), GTK_RESPONSE_OK);
See the splendid documentation.