Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/ContextMenu with Fonts on Mac
Function:
Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/ContextMenu with Fonts on Mac
This example is the version from Sun, 17th Mar 2012.
Project "ContextMenu with Fonts on Mac.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() CarbAppEvnt1=new CAE1 CarbAppEvnt1.Listen End EventHandler
Property CarbAppEvnt1 As CAE1
End Class
Class Window1 Inherits Window
Control Lbl1 Inherits Label
ControlInstance Lbl1 Inherits Label
End Control
EventHandler Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean dim i As Integer dim n As MenuItem dim s As String dim t As String s=Lbl1.TextFont n=new MenuItem n.Checked=s="System" n.Name="Font" n.Text="System" base.Append n n=new MenuItem n.Text="-" base.Append n for i=0 to FontCount-1 t=Font(i) n=new MenuItem n.Checked=t=s n.Name="Font" n.Text=t base.Append n next Return True End EventHandler
EventHandler Function ContextualMenuAction(hitItem as MenuItem) As Boolean Lbl1.TextFont=hitItem.Text Return True End EventHandler
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 CAE1 Inherits CarbonApplicationEventsMBS
EventHandler Sub MenuPopulate(MenuHandle as integer) dim i As Integer dim m as new menumbs dim n As MenuMBS m.handle=MenuHandle if m.Count>1 then 'If there are at least 2 menu items... if m.Text(1)="System" and m.Text(2)="-" and m.Text(0)="" then 'It's our font menu for i=1 to m.Count 'Apply to every menu item... m.FontName(i)=m.Text(i) '...the font it needs next end if end if End EventHandler
Property DockMenu As MenuMBS
End Class
End Project

Feedback, Comments & Corrections

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





Links
MBS Xojo Plugins