Rank: Advanced Member Groups: Registered
Joined: 11/01/2018(UTC) Posts: 134 Location: Wisconsin Was thanked: 62 time(s) in 39 post(s)
|
Salutations! If you are used to Mathcad 15.0, you will have difficulty Creating/Navigating a worksheet because SMath has limited support when it comes to hotkeys/keyboard operations. SMath requires a fair amount of operations to be achieved via the mouse [🖰], which can be annoying (and time consuming) if you wish to type a lot of math/text quickly. Whereas I did identify some remedies/workarounds (i.e., insert ▮⊕▮ (xor Operator) via HEX code 00A4 [Currency sign symbol: ¤]), this remains a work-around and does not actually address the issue. Therefore, I developed the following code: 'VB.net - Framework 2.0; Windows 10 Pro x64; SMath 0.99.7822.147 [English, USA] keybinding_with_IPluginMenuExtender.vb.txt (38kb) downloaded 22 time(s).
Document is uploaded as a (*.txt), remove extension for file to be treated as a VB class (*.vb ): Please practice good judgment before downloading and opening any executable files!Code will compile, you may copy/paste the following into your project: Code:
Imports SMath.Manager
Imports SMath.Controls
Public Class FormControl_4a_Implementer : Implements IPluginMenuExtender
Private disposedValue As Boolean 'Generated by Default
Public Sub Initialize() Implements IPlugin.Initialize
'Throw New NotImplementedException() 'Generated by Default; Comment out/delete for plugin to execute
End Sub
Public Const CURSOR_STEP As Integer = 10 'Number of pixels to move cursor; referenced by: (btnKeyPress11 .. btnKeyPress15)
'''==============================================================================================
''' <name>GetMenuItem</name>
''' <author>Kenneth M. Lemens (username: lemensk)</author>
''' <date>2022-12-15</date>
''' <type>IPluginMenuExtender</type>
''' <summary>Adds MenuButtons to the Menu Bar
''' MenuButtons are assigned Shortcut keys, to be used within a document (regions need not be selected)
''' Shortcut keys to Mimic some Mathcad 15.0 Keypresses, enhances ability to insert operators within SMath
''' MENU BAR BUTTON LAYOUT:
''' [Tools]
''' [Keyboard Extension]
''' - 「Ctrl」+「%」 :: Boolean XOR (Exclusive or)
''' - 「Ctrl」+「!」 :: Boolean NOT
''' - 「Ctrl」+「-」 :: Insert a Macron (bar) Above the Previous Character
''' - 「Ctrl」+「_」 :: Insert a Macron Below (undlerline) Above Previous Character
''' - 「Ctrl」+「+」numpad :: Plus Minus Sign (Returns a set of 2: the sum And difference)
''' - 「Ctrl」+「-」numpad :: Minus Plus Sign (Returns a set of 2: the difference And sum)
''' - 「Ctrl」+「~」 :: Approximately Equal to (「Ctrl」+「Alt」+「=」)
''' - 「Ctrl」+「Shift」+「~」 :: Approximately NOT Equal to
''' - 「Ctrl」+「;」 :: Range variable [a .. b] (step = 1)
''' - 「Ctrl」+「4」 :: Vector sum
''' - 「Ctrl」+「Shift」+「Enter」 :: Move ✛ to Start of Next Line (Line Feed & Carriage Return Only) "Ignore Region Interaction" Mode --- DocumentPointer - Line Feed [↩]
''' - 「Ctrl」+[↓] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [↓]
''' - 「Ctrl」+[←] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [←]
''' - 「Ctrl」+[→] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [→]
''' - 「Ctrl」+[↑] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [↑]
''' </summary>
''' <param name="_profileOfSession">(byRef) SMath.Manager.SessionProfile (Not Utilized)</param>
''' <returns>TYPE: MenuButton() - List of MenuButtons) </returns>
''' <remarks>
''' Imports: SMath.Manager; SMath.Controls
''' Implements: SMath.Controls.IPluginMenuExtender
''' References: KEY CODES for "ShortcutKey" property (NOTE: Operator 'Or' does not serve as a boolean operator)
''' https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.keys?view=windowsdesktop-7.0
''' Unstructured Exit: FALSE
''' Error Handler: TRUE (MenuButton Subs contain 'Try' statements)
''' </remarks>
'''==============================================================================================
Public Function GetMenuItem(_profileOfSession As SessionProfile) As MenuButton() Implements IPluginMenuExtender.GetMenuItem
'Throw New NotImplementedException() 'Generated by Default; Comment out/delete for plugin to execute
'「Ctrl」+「%」 :: Boolean XOR (Exclusive or)
Dim btnKeyPress01 As SMath.Controls.MenuButton
btnKeyPress01 = New MenuButton("Boolean XOR", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("¤", SMath.Manager.TermType.Operator, 2))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("¤")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress01.ShortcutKey = InputKeys.Control Or InputKeys.Shift Or InputKeys.D5
'「Ctrl」+「!」 :: Boolean NOT
Dim btnKeyPress02 As SMath.Controls.MenuButton
btnKeyPress02 = New MenuButton("Boolean NOT", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("¬", SMath.Manager.TermType.Operator, 1))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("¬")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress02.ShortcutKey = InputKeys.Control Or InputKeys.Shift Or InputKeys.D1
'「Ctrl」+「-」 :: Insert a Macron (bar) Above the Previous Character
Dim btnKeyPress03 As SMath.Controls.MenuButton
btnKeyPress03 = New MenuButton("Macron Above (x̅)", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
'do nothing!
Else
_args.CurrentRegion.OnCommandSend("̅")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress03.ShortcutKey = InputKeys.Control Or InputKeys.OemMinus
'「Ctrl」+「_」 :: Insert a Macron Below (undlerline) Above Previous Character
Dim btnKeyPress04 As SMath.Controls.MenuButton
btnKeyPress04 = New MenuButton("Macron Below (x̲)", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
'do nothing!
Else
_args.CurrentRegion.OnCommandSend("̲")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress04.ShortcutKey = InputKeys.Control Or InputKeys.Shift Or InputKeys.OemMinus
'「Ctrl」+「+」numpad :: Plus Minus Sign (Returns a set of 2: the sum And difference)
Dim btnKeyPress05 As SMath.Controls.MenuButton
btnKeyPress05 = New MenuButton("Plus Minus (±)", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("±", SMath.Manager.TermType.Operator, 1))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("±")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress05.ShortcutKey = InputKeys.Control Or InputKeys.Add
'「Ctrl」+「-」numpad :: Minus Plus Sign (Returns a set of 2: the difference And sum)
Dim btnKeyPress06 As SMath.Controls.MenuButton
btnKeyPress06 = New MenuButton("Minus Plus (∓)", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("∓", SMath.Manager.TermType.Operator, 1))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("∓")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress06.ShortcutKey = InputKeys.Control Or InputKeys.Subtract
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'Supported in Later Versions (v1.00+) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
'「Ctrl」+「~」 :: Approximately Equal to (「Ctrl」+「Alt」+「=」)
Dim btnKeyPress07 As SMath.Controls.MenuButton
btnKeyPress07 = New MenuButton("Approx. Equal (≈)", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("≈", SMath.Manager.TermType.Operator, 2))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("≈")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress07.ShortcutKey = InputKeys.Control Or InputKeys.Oemtilde
'「Ctrl」+「Shift」+「~」 :: Approximately NOT Equal to
Dim btnKeyPress08 As SMath.Controls.MenuButton
btnKeyPress08 = New MenuButton("Approx. NOT Equal (≉)", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("≉", SMath.Manager.TermType.Operator, 2))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("≉")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress08.ShortcutKey = InputKeys.Control Or InputKeys.Shift Or InputKeys.Oemtilde
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'Functions (not operators) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'「Ctrl」+「;」 :: Range variable [a .. b] (step = 1)
Dim btnKeyPress09 As SMath.Controls.MenuButton
btnKeyPress09 = New MenuButton("Insert range ( ▮..▮ )", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("range", SMath.Manager.TermType.Function, 2))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("range(,")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress09.ShortcutKey = InputKeys.Control Or InputKeys.OemSemicolon
'「Ctrl」+「4」 :: Vector sum
Dim btnKeyPress10 As SMath.Controls.MenuButton
btnKeyPress10 = New MenuButton("Insert Summation ( Σ ▮ )", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
Dim Bénézet As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
Dim Rhône = New List(Of SMath.Manager.Term)
Rhône.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
Rhône.Add(New SMath.Manager.Term("sum", SMath.Manager.TermType.Function, 1))
Bénézet.Terms = Rhône.ToArray
Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Bénézet}), 0)
_args.Worksheet.CreateRegions(Avignon, 0, 0, , )
Else
_args.CurrentRegion.OnCommandSend("sum(")
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress10.ShortcutKey = InputKeys.Control Or InputKeys.D4
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'Navigation (move Document Pointer (Crosshair Cursor)) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'「Ctrl」+「Shift」+「Enter」 :: Move ✛ to Start of Next Line (Line Feed & Carriage Return Only) "Ignore Region Interaction" Mode --- DocumentPointer - Line Feed [↩]
Dim btnKeyPress11 As SMath.Controls.MenuButton
btnKeyPress11 = New MenuButton("DocumentPointer - Line Feed [↩]", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(5, _args.Worksheet.Pointer.Location.Y + CURSOR_STEP))
Else
_args.Worksheet.UnfocusRegions()
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(5, _args.Worksheet.Pointer.Location.Y + _args.CurrentRegion.Size.Height + CURSOR_STEP))
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress11.ShortcutKey = InputKeys.Control Or InputKeys.Shift Or InputKeys.Return
'「Ctrl」+[↓] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [↓]
Dim btnKeyPress12 As SMath.Controls.MenuButton
btnKeyPress12 = New MenuButton("DocumentPointer [↓]", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X,
_args.Worksheet.Pointer.Location.Y + CURSOR_STEP))
Else
_args.Worksheet.UnfocusRegions()
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X,
_args.Worksheet.Pointer.Location.Y + _args.CurrentRegion.Size.Height + CURSOR_STEP))
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress12.ShortcutKey = InputKeys.Control Or InputKeys.Down
'「Ctrl」+[←] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [←]
Dim btnKeyPress13 As SMath.Controls.MenuButton
btnKeyPress13 = New MenuButton("DocumentPointer [←]", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X - CURSOR_STEP,
_args.Worksheet.Pointer.Location.Y))
Else
_args.Worksheet.UnfocusRegions()
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X - CURSOR_STEP,
_args.Worksheet.Pointer.Location.Y + _args.CurrentRegion.Size.Height / 2))
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress13.ShortcutKey = InputKeys.Control Or InputKeys.Left
'「Ctrl」+[→] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [→]
Dim btnKeyPress14 As SMath.Controls.MenuButton
btnKeyPress14 = New MenuButton("DocumentPointer [→]", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X + CURSOR_STEP,
_args.Worksheet.Pointer.Location.Y))
Else
_args.Worksheet.UnfocusRegions()
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X + _args.CurrentRegion.Size.Width + CURSOR_STEP,
_args.Worksheet.Pointer.Location.Y + _args.CurrentRegion.Size.Height / 2))
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress14.ShortcutKey = InputKeys.Control Or InputKeys.Right
'「Ctrl」+[↑] :: Enter "Ignore Region Interaction" Mode --- DocumentPointer [↑]
Dim btnKeyPress15 As SMath.Controls.MenuButton
btnKeyPress15 = New MenuButton("DocumentPointer [↑]", Sub(_args As MenuButtonArgs)
Try
If IsNothing(_args.CurrentRegion) Then
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X,
_args.Worksheet.Pointer.Location.Y - CURSOR_STEP))
Else
_args.Worksheet.UnfocusRegions()
_args.Worksheet.Pointer.SetLocation(New Drawing.Point(_args.Worksheet.Pointer.Location.X,
_args.Worksheet.Pointer.Location.Y - CURSOR_STEP))
End If
Catch
'do nothing!
End Try
End Sub) : btnKeyPress15.ShortcutKey = InputKeys.Control Or InputKeys.Up
'Proof of Concept: Assign [F1]
Dim btnKeyPressHelp = New MenuButton("Help / About", Sub(_args As MenuButtonArgs)
MsgBox("======================================" & vbCrLf &
"name: GetMenuItem" & vbCrLf &
"author: Kenneth M. Lemens (username: lemensk)" & vbCrLf &
"date: 2022-12-15" & vbCrLf &
"type: IPluginMenuExtender" & vbCrLf &
"summary:Adds MenuButtons to the Menu Bar (w/ hotkeys):" & vbCrLf &
" Hotkeys work within region, or creates a new region" & vbCrLf &
"https://en.smath.com/forum/Default.aspx?g=posts&t=23271" & vbCrLf & vbCrLf &
" || MENU BAR BUTTON LAYOUT ||" & vbCrLf &
" [Tools]" & vbCrLf &
" [Keyboard Extension]" & vbCrLf &
" - 「Ctrl」+「%」 - ▮⊕▮ Boolean XOR (Exclusive or) " & vbCrLf &
" - 「Ctrl」+「!」 - ¬▮ Boolean NOT" & vbCrLf &
" - 「Ctrl」+「-」 - x̅ Insert a Macron Above" & vbCrLf &
" - 「Ctrl」+「_」 - x̲ Insert a Macron Below" & vbCrLf &
" - 「Ctrl」+「+」numpad - ±▮; ▮±▮ Plus Minus Sign" & vbCrLf &
" - 「Ctrl」+「-」numpad - ∓▮; ▮∓▮ Minus Plus Sign" & vbCrLf &
" - 「Ctrl」+「~」 - ▮≈▮ Approx. Equal to (「Ctrl」+「Alt」+「=」)" & vbCrLf &
" - 「Ctrl」+「Shift」+「~」 - ▮≉▮ Approx. NOT Equal to" & vbCrLf &
" - 「Ctrl」+「;」 - ▮..▮ Range Function" & vbCrLf &
" - 「Ctrl」+「4」 - Σ▮ Vector Sum" & vbCrLf &
" - 「Ctrl」+「Shift」+「Enter」 - Move ✛ to Start of Next Line" & vbCrLf &
" - 「Ctrl」+Arrows - Ignore Regions when moving cursor" & vbCrLf &
"======================================" & vbCrLf & vbCrLf &
"Press [Ctrl]+[C] to Copy this message to your clipboard...", vbOKOnly & vbInformation, "[Tools]→[Keyboard Extension] (by lemensk)")
End Sub) : btnKeyPressHelp.ShortcutKey = InputKeys.F1
Dim btnKeyboardMenu = (New MenuButton("Keyboard Extension"))
With btnKeyboardMenu
.Location = MenuButtonLocation.ToolsMenu
.AppendChild(btnKeyPress01)
.AppendChild(btnKeyPress02)
.AppendChild(btnKeyPress03)
.AppendChild(btnKeyPress04)
.AppendChild(btnKeyPress05)
.AppendChild(btnKeyPress06)
.AppendChild(btnKeyPress07)
.AppendChild(btnKeyPress08)
.AppendChild(btnKeyPress09)
.AppendChild(btnKeyPress10)
.AppendChild(btnKeyPress11)
.AppendChild(btnKeyPress12)
.AppendChild(btnKeyPress13)
.AppendChild(btnKeyPress14)
.AppendChild(btnKeyPress15)
.AppendChild(btnKeyPressHelp)
End With
Return (New MenuButton() {btnKeyboardMenu})
End Function
' ========================================================================================================
' \\\\ GENERATED SUBS //// ===============================================================================
' ========================================================================================================
Protected Overridable Sub Dispose(disposing As Boolean)
If Not disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects)
End If
' TODO: free unmanaged resources (unmanaged objects) and override finalizer
' TODO: set large fields to null
disposedValue = True
End If
End Sub
' ' TODO: override finalizer only if 'Dispose(disposing As Boolean)' has code to free unmanaged resources
' Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in 'Dispose(disposing As Boolean)' method
' Dispose(disposing:=False)
' MyBase.Finalize()
' End Sub
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in 'Dispose(disposing As Boolean)' method
Dispose(disposing:=True)
GC.SuppressFinalize(Me)
End Sub
End Class
Preview:
Code:---------------------------
[Tools]→[Keyboard Extension] (by lemensk)
---------------------------
======================================
name: GetMenuItem
author: Kenneth M. Lemens (username: lemensk)
date: 2022-12-15
type: IPluginMenuExtender
summary:Adds MenuButtons to the Menu Bar (w/ hotkeys):
Hotkeys work within region, or creates a new region
https://en.smath.com/forum/Default.aspx?g=posts&t=23271
|| MENU BAR BUTTON LAYOUT ||
[Tools]
[Keyboard Extension]
- 「Ctrl」+「%」 - ▮⊕▮ Boolean XOR (Exclusive or)
- 「Ctrl」+「!」 - ¬▮ Boolean NOT
- 「Ctrl」+「-」 - x̅ Insert a Macron Above
- 「Ctrl」+「_」 - x̲ Insert a Macron Below
- 「Ctrl」+「+」numpad - ±▮; ▮±▮ Plus Minus Sign
- 「Ctrl」+「-」numpad - ∓▮; ▮∓▮ Minus Plus Sign
- 「Ctrl」+「~」 - ▮≈▮ Approx. Equal to (「Ctrl」+「Alt」+「=」)
- 「Ctrl」+「Shift」+「~」 - ▮≉▮ Approx. NOT Equal to
- 「Ctrl」+「;」 - ▮..▮ Range Function
- 「Ctrl」+「4」 - Σ▮ Vector Sum
- 「Ctrl」+「Shift」+「Enter」 - Move ✛ to Start of Next Line
- 「Ctrl」+Arrows - Ignore Regions when moving cursor
======================================
Press [Ctrl]+[C] to Copy this message to your clipboard...
---------------------------
OK
---------------------------
Q: ) Will you be deploying this as a SMath Extension?A: ) No, I do not plan to. As to why, the reason is simple: I do not know how this plugin will behave across different languages/keyboard configurations/operating systems. Before I could release a plugin I am proud of, I would need to address the implications that will result from these different configurations. In addition, such a plugin would beg the developer to permit users to customize key bindings to any given action; I do not have the time to develop such a great utility. Finally: such a plugin has the dangers of being greedy; I would not be able to guarantee such a plugin to respect (either by yielding or overtaking) keystrokes reserved by any given plugin. Q: ) Why is this code written in Visual Basic and not C++A: ) VB.net is not the better language, but rather I cannot ignore the benefits of VB within my profession. It is easy to read, less prone to make syntax errors, has a large range of implementations from VBScript in Mathcad, to VBA in MSOffice, from VB6 to VB.net in VSTO/Desktop applications. With that being said, I will not be posting the C++ equivalent as I am not proficient in doing so; I apologize for the inconvenience. With that being said, here are some of my 'lessons learned' during my research:- These shortcut key commands must utilize Modifier keys; exceptions will be thrown if a shortcut is specified with a single keystroke (ie., you cannot bind 「;」, but you can bind 「Ctrl」+「;」). An exception to this rule may be the F1-F12 keys.
- Depending if a region is selected, a keypress will need to be handled differently to achieve the desired results. The code provided above will try to create a new region if nothing is selected; else it will send an action into the current region.
- All Menu Buttons are NOT created equal! While I did not explore this in earnest, I did observe that the shortcut keys bound to context menu buttons will not work unless the context menu is expanded. In addition, shortcut keys bound to menu buttons within the INSERT menu will not execute if a region is selected (that is this, for these keybindings to work, the developer must utilize IPluginMenuExtender as IPluginCustomRegion can only influence the INSERT menu)
- These shortcut keys need not to be limited to inserting Mathematical operators! You will notice I developed keybindings so that the Document Pointer (✛) can be moved via keyboard without entering a region. This is huge as navigation solely by the keyboard is nigh impractical.
May this be of Good Help, Merry Christmas; - Kenny Lemens, P.E. ᵂᴵ |