Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/ContextMenu with Fonts on Mac
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/ContextMenu with Fonts on Mac
This example is the version from Sat, 30th Jan 2009.
Notes: Last modified: Sat, 30th Jan 2009
Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = E&xit
Const kEditClear = &Delete

// Properties
Dim CarbAppEvnt1 As CAE1

// Event implementations
Sub Open()
CarbAppEvnt1=new CAE1
CarbAppEvnt1.Listen
End Sub
End Class

Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance

// Event implementations
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 Function
Function ContextualMenuAction(hitItem as MenuItem) As Boolean
Lbl1.TextFont=hitItem.Text
Return True
End Function
End Class

Class CAE1
Inherits CarbonApplicationEventsMBS
// Properties
Dim DockMenu As MenuMBS

// Event implementations
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 Sub
End Class





Links
MBS REAL studio Plugins - Pfarrgemeinde Messdiener Nickenich