Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSFontPanel
This example is the version from Sun, 17th Mar 2012.
Project "NSFontPanel.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action()
dic = new Dictionary
font = NSFontMBS.systemFontOfSize(NSFontMBS.systemFontSize)
f = new MyNSFontPanelMBS
f.setPanelFont font, false
f.orderFront
End EventHandler
End Control
Control Liste Inherits Listbox
ControlInstance Liste Inherits Listbox
End Control
Property dic As Dictionary
Property f As MyNSFontPanelMBS
Property font As NSFontMBS
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 MyNSFontPanelMBS Inherits NSFontPanelMBS
EventHandler Sub changeAttributes()
dim oldAttr as Dictionary = window1.dic
dim newAttr as Dictionary = convertAttributes(oldAttr)
window1.dic = newAttr
for each k as Variant in newAttr.Keys
dim v as Variant = newAttr.Value(k)
if v isa NSColorMBS then
dim n as NSColorMBS = v
window1.Liste.AddRow k.StringValue+" -> "+n.description
else
window1.Liste.AddRow k.StringValue+" -> "+v.StringValue
end if
next
End EventHandler
EventHandler Sub changeFont()
dim oldFont as NSFontMBS = window1.font
dim newFont as NSFontMBS = convertFont(oldFont)
window1.font = newFont
window1.Liste.AddRow newFont.displayName
window1.Liste.AddRow newFont.description
End EventHandler
End Class
End Project
The items on this page are in the following plugins: MBS MacCocoa Plugin.