MBS Xojo Conference
6/7th September 2018, Munich

« FileMaker Cloud 1.17.… | Home | FileMaker DevCon Scan… »

Custom menu checkmarks

Did you know you can get custom checkmark icons with MBS Xojo Plugins on Mac by using NSMenuItemMBS class?

Here is some example code which sits in App. EnableMenuItems event and modifies the menu just before it's showing:

EventHandler Sub EnableMenuItems() FileUnchecked.enable // normally checked FileChecked.checked = true FileChecked.enable FileDot.enable FileDot.checked = true // with bullet via constructor dim n1 as new NSMenuItemMBS(fileDot) n1.onStateImage = NSImageMBS.imageNamed("NSMenuItemBullet") FileDiamond.enable FileDiamond.checked = true // with diamond via function dim n2 as NSMenuItemMBS = NSMenuItemMBS.MenuItem(FileDiamond) n2.onStateImage = NSImageMBS.imageNamed("NSMenuItemDiamond") FileIcon.enable FileIcon.checked = true // with icon as checkmark dim n3 as NSMenuItemMBS = NSMenuItemMBS.MenuItem(FileIcon) dim icon as NSImageMBS = NSWorkspaceMBS.iconForFileType("com.xojo.project.binary") icon.setSize(16,16) n3.onStateImage = icon FileCustomImage.enable FileCustomImage.checked = true // with custom image as checkmark dim p as new Picture(32,32) dim g as Graphics = p.Graphics g.ForeColor = &c0000FF g.FillOval 0, 0, p.Width, p.Height dim n4 as NSMenuItemMBS = NSMenuItemMBS.MenuItem(FileCustomImage) dim image as new NSImageMBS(p) image.setSize(16,16) n4.onStateImage = image End EventHandler
The example project will be included soon with 18.3 plugins.
01 06 18 - 20:20
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.