-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an API to easily build Mac Os menus
- Loading branch information
Showing
7 changed files
with
307 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
" | ||
A Cocoa menu separator. I'm also a menu item. | ||
" | ||
Class { | ||
#name : #CocoaMenuSeparator, | ||
#superclass : #Object, | ||
#category : #'ObjectiveC-Cocoa-Menus' | ||
} | ||
|
||
{ #category : #adding } | ||
CocoaMenuSeparator >> addToMenu: aCocoaMenu [ | ||
<ignoreNotImplementedSelectors: #(#separatorItem)> | ||
|
||
| separator | | ||
separator := #NSMenuItem inObjC separatorItem. | ||
aCocoaMenu nsMenu addItem: separator | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
" | ||
I represent the Mac os ""Services"" menu. | ||
You can use me to add a ""Services"" entry to your app menu. | ||
" | ||
Class { | ||
#name : #CocoaServicesMenu, | ||
#superclass : #CocoaMenu, | ||
#category : #'ObjectiveC-Cocoa-Menus' | ||
} | ||
|
||
{ #category : #configuring } | ||
CocoaServicesMenu >> beServicesMenu [ | ||
<ignoreNotImplementedSelectors: #(#setServicesMenu:)> | ||
|
||
#NSApplication inObjC sharedApplication setServicesMenu: nsMenu | ||
] | ||
|
||
{ #category : #private } | ||
CocoaServicesMenu >> buildNSMenu [ | ||
|
||
nsMenu := self servicesMenu. | ||
nsMenu isNull | ||
ifTrue: [ | ||
super buildNSMenu. | ||
self beServicesMenu ] | ||
ifFalse: [ nsTitle := title asNSString ]. | ||
^ nsMenu | ||
] | ||
|
||
{ #category : #initialization } | ||
CocoaServicesMenu >> initialize [ | ||
|
||
super initialize. | ||
title := 'Services' | ||
] | ||
|
||
{ #category : #accessing } | ||
CocoaServicesMenu >> servicesMenu [ | ||
"Get the Application services menu if set or null" | ||
|
||
^ #NSApplication inObjC sharedApplication servicesMenu | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.