Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Hotkeys
This example is the version from Wed, 4th Aug 2015.
Project "Hotkeys.xojo_binary_project"
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
EventHandler Sub Open()
dim keyCodeReturn as integer = HotKeyMBS.KeyCodeForText("return")
dim keyCodeF5 as integer = HotKeyMBS.KeyCodeForText("F5")
// with subclass
HotKeyReturn = new MyHotKey(keyCodeReturn, HotKeyMBS.ShiftKey + HotKeyMBS.OptionKey)
// now with addhandler:
HotKeyF5 = new HotKeyMBS(keyCodeF5, HotKeyMBS.ControlKey)
AddHandler HotKeyF5.KeyDown, WeakAddressOf HotKeyF5Handler
End EventHandler
Protected Sub HotKeyF5Handler(h as HotKeyMBS)
Listbox1.AddRow "Control-F5 pressed"
MsgBox "Control-F5 pressed"
End Sub
Property Protected HotKeyF5 As HotKeyMBS
Property Protected HotKeyReturn As MyHotKey
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class MyHotKey Inherits HotKeyMBS
EventHandler Sub KeyDown()
Window1.ListBox1.AddRow "Hotkey pressed"
Window1.CollapsedMBS = not Window1.CollapsedMBS
End EventHandler
EventHandler Sub KeyUp()
Window1.ListBox1.AddRow "Hotkey released"
End EventHandler
End Class
End Project
The items on this page are in the following plugins: MBS Util Plugin.