Platforms to show: All Mac Windows Linux Cross-Platform
/MacControls/NSTextField Focus on KeyDown
Required plugins for this example: MBS MacFrameworks Plugin, MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/NSTextField Focus on KeyDown
This example is the version from Sat, 26th Oct 2012.
Project "NSTextField Focus on KeyDown.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control CocoaControlMBS1 Inherits CocoaControlMBS
ControlInstance CocoaControlMBS1 Inherits CocoaControlMBS
EventHandler Function GetView() As NSViewMBS
n = new NSTextFieldMBS
Return n
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
ClearFocus
End EventHandler
End Control
EventHandler Function KeyDown(Key As String) As Boolean
CocoaControlMBS1.setFocus
n.StringValue = key
dim e as NSTextMBS = n.currentEditor
if e<>Nil then
e.selectedRange = new NSRangeMBS(e.textLength,0)
end if
Return true
End EventHandler
Property n As NSTextFieldMBS
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
End Project
The items on this page are in the following plugins: MBS MacControls Plugin.