Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/Media Keys
Required plugins for this example: MBS MacBase Plugin, MBS MacFrameworks Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/Media Keys
This example is the version from Sun, 17th Mar 2012.
Project "Media Keys.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() MediaKeys.startWatchingMediaKeys End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() MediaKeys.stopWatchingMediaKeys End EventHandler
End Control
EventHandler Sub Open() MediaKeys = new MyMediaKeysMBS // accept all 24 keys. Default is just 3 media keys for i as integer = 0 to 23 MediaKeys.Keys(i) = MediaKeysMBS.kModeEventAndBlock next End EventHandler
Property MediaKeys As MyMediaKeysMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyMediaKeysMBS Inherits MediaKeysMBS
EventHandler Sub receivedMediaKeyEvent(e as NSEventMBS, keyCode as integer, keyFlags as integer, keyState as integer, keyRepeat as integer) dim l as listbox = window1.List dim s as string = " - "+str(ticks) if keyState = 1 then s = s + " down" else s = s + " up" end if if keyRepeat>0 then s = s + " repeated" end if dim name as string Select case KeyCode case me.kMediaKeySoundUp name="SoundUp" case me.kMediaKeySoundDown name="SoundDown" case me.kMediaKeyBrightnessUp name="BrightnessUp" case me.kMediaKeyBrightnessDown name="BrightnessDown" case me.kMediaKeyCapsLock name="CapsLock" case me.kMediaKeyHelp name="Help" case me.kMediaKeyPower name="Power" case me.kMediaKeyMute name="Mute" case me.kMediaKeyUpArrow name="UpArrow" case me.kMediaKeyDownArrow name="DownArrow" case me.kMediaKeyNumLock name="NumLock" case me.kMediaKeyContrastUp name="ContrastUp" case me.kMediaKeyContrastDown name="ContrastDown" case me.kMediaKeyLaunchPanel name="LaunchPanel" case me.kMediaKeyEject name="Eject" case me.kMediaKeyVideoMirror name="VideoMirror" case me.kMediaKeyPlay name="Play" case me.kMediaKeyNext name="Next" case me.kMediaKeyPrevious name="Previous" case me.kMediaKeyFast name="Fast" case me.kMediaKeyRewind name="Rewind" case me.kMediaKeyIlluminationUp name="IlluminationUp" case me.kMediaKeyIlluminationDown name="IlluminationDown" case me.kMediaKeyIlluminationToggle name="IlluminationToggle" else name = "other: "+str(KeyCode) end Select l.InsertRow 0, name+s End EventHandler
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacFrameworks Plugin.

MBS Xojo PDF Plugins