Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Key Bindings in Settings?

$
0
0

Hi all,

I'm in the process of converting my macros into Add-ins.

Nearly all of my macros are bound to keystroke combinations and I want to bind my Add-in methods to the same keys. I'm hoping that I can do this via my setting XML file. The bindings are maintained within the "UserShortcuts" element like thus:


<Category name="Environment_KeyBindings" Category="{F09035F1-80D2-4312-8EC4-4D354A4BCB4C}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_KeyBindings" PackageName="Visual Studio Environment Package">
  <Version>10.0.0.0</Version>
  <KeyboardShortcuts>
    <UserShortcuts>
      <Shortcut Command="Macros.MyMacros.Main_Module.go_to_symbol_def" Scope="Text Editor">Ctrl+Alt+D</Shortcut>


How could I do this for Add-in methods?

How could I do this programmatically?


I've seen this example:

Public Sub OnConnection(ByVal application As Object, ByVal  _
  connectMode As ext_ConnectMode, ByVal addInInst As Object, ByRef  _
  custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    BindingsExample(_applicationObject)
End Sub

Sub BindingsExample(ByVal dte As DTE2)
    Dim cmds As Commands
    Dim cmd As Command
    Try
        ' Set references to the Commands collection and the 
        ' File.NewFile command.
        cmds = DTE.Commands
        cmd = cmds.Item("File.NewFile")

        ' Assigns the command (File.NewFile) globally to the F2 key.
        cmd.Bindings = "Global::F2"
        MsgBox("key remapped")
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub
http://msdn.microsoft.com/en-us/library/vstudio/ms228753.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

I need a tip as to how I would get a Command reference to a method within my add-in.

Any assistance with this would be greatly appreciated.

      

Wally


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>