Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacFrameworks Plugin, MBS MacCF Plugin
Last modified Sat, 7th Mar 2014.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /MacFrameworks/Event Logging
Download this example: Event Logging.zip
Project "Event Logging.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
if not m.Available then
MsgBox "This functionality needs Mac OS X 10.6."
quit
end if
m = new MyNSEventMonitor
call m.addLocalMonitorForEventsMatchingMask(NSEventMBS.NSAnyEventMask)
call m.addGlobalMonitorForEventsMatchingMask(NSEventMBS.NSAnyEventMask)
window1.List.AddRow "Trusted: "+str(AccessibilityMBS.IsProcessTrusted)
End EventHandler
Property m As MyNSEventMonitor
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyNSEventMonitor Inherits NSEventMonitorMBS
EventHandler Sub GlobalEvent(e as NSEventMBS)
window1.List.AddRow "Global: "+e.description
window1.List.ScrollPosition = window1.List.ListCount
End EventHandler
EventHandler Function LocalEvent(e as NSEventMBS) As NSEventMBS
window1.List.AddRow "Local: "+e.description
window1.List.ScrollPosition = window1.List.ListCount
// Return nil to block event
Finally
// Return event, because else your app can't do anything
Return e
End EventHandler
End Class
End Project
Download this example: Event Logging.zip
The items on this page are in the following plugins: MBS MacFrameworks Plugin.