adding menu items to the right click app menu in the dock casues them to be re-added each time i clickWhen to remove dynamic NSMenuItem's from an NSMenuHow to create a menu when a user right-clicks on the dock-icon of cocoa app on Mac?Cocoa osx: Add a menu item on dock elements for all running applicationsAdd a menu item for OS X Trash dock menuMenu items don't appear in nibless StatusMenu app?JXA Creating an app delegate causes app to crashApplication Dock Menu with image on menu itemAdding item to Contextual menu and send highlighted text to other app on MacOSwhy does NSApplication sharedApplication mainMenu return nil?macOS: Add commands to existing application right-click menu in dockCreate a menu inside of a view (macos, cocoa, swift)?
How do I subvert the tropes of a train heist?
Uses of T extends U?
Which noble houses were destroyed during the Game of Thrones?
How can I find where certain bash function is defined?
Can a wire having a 610-670 THz (frequency of blue light) AC frequency supply, generate blue light?
Is there any use case for the bottom type as a function parameter type?
File globbing pattern, !(*example), behaves differently in bash script than it does in bash shell
Mother abusing my finances
Is a post-climate apocolypse city in which many or most insects have disappeared realistic?
What are the benefits of cryosleep?
Yandex Programming Contest: Alarms
How can I prevent interns from being expendable?
I think I may have violated academic integrity last year - what should I do?
How to capture more stars?
What is a subpixel in Super Mario Bros, and how does it relate to wall clipping?
Leading and Suffering Numbers
How to extract lower and upper bound in numeric format from a confidence interval string?
Black-and-white film where monster/alien gets fried
Is it ok to put a subplot to a story that is never meant to contribute to the development of the main plot?
If a massive object like Jupiter flew past the Earth how close would it need to come to pull people off of the surface?
Plot exactly N bounce of a ball
What does "Marchentalender" on the front of a postcard mean?
Restoring order in a deck of playing cards
Future enhancements for the finite element method
adding menu items to the right click app menu in the dock casues them to be re-added each time i click
When to remove dynamic NSMenuItem's from an NSMenuHow to create a menu when a user right-clicks on the dock-icon of cocoa app on Mac?Cocoa osx: Add a menu item on dock elements for all running applicationsAdd a menu item for OS X Trash dock menuMenu items don't appear in nibless StatusMenu app?JXA Creating an app delegate causes app to crashApplication Dock Menu with image on menu itemAdding item to Contextual menu and send highlighted text to other app on MacOSwhy does NSApplication sharedApplication mainMenu return nil?macOS: Add commands to existing application right-click menu in dockCreate a menu inside of a view (macos, cocoa, swift)?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
so i've been trying to add items to the right click menu
when u right click on the app icon in the dock in macos
but when i do it with this code whenver i right click the app icon
it re-adds the menu item
class myclass: NSObject , NSApplicationDelegate{
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
swift macos cocoa
|
show 1 more comment
so i've been trying to add items to the right click menu
when u right click on the app icon in the dock in macos
but when i do it with this code whenver i right click the app icon
it re-adds the menu item
class myclass: NSObject , NSApplicationDelegate{
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
swift macos cocoa
where is yourdockMenu
defined?
– Amir Khan
Mar 24 at 8:48
@AmirKhan outside of myclass as "let dockMenu = NSMenu()"
– bibble triple
Mar 24 at 8:52
Follow this link - stackoverflow.com/questions/6817214/…
– Amir Khan
Mar 24 at 8:58
@vadian if i do that i cant acees the menu item from outside of that function
– bibble triple
Mar 24 at 9:06
try to remove all menu items before adding new items.
– Amir Khan
Mar 24 at 9:07
|
show 1 more comment
so i've been trying to add items to the right click menu
when u right click on the app icon in the dock in macos
but when i do it with this code whenver i right click the app icon
it re-adds the menu item
class myclass: NSObject , NSApplicationDelegate{
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
swift macos cocoa
so i've been trying to add items to the right click menu
when u right click on the app icon in the dock in macos
but when i do it with this code whenver i right click the app icon
it re-adds the menu item
class myclass: NSObject , NSApplicationDelegate{
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
swift macos cocoa
swift macos cocoa
edited Mar 24 at 8:53
a.masri
1,8371825
1,8371825
asked Mar 24 at 8:44
bibble triplebibble triple
65
65
where is yourdockMenu
defined?
– Amir Khan
Mar 24 at 8:48
@AmirKhan outside of myclass as "let dockMenu = NSMenu()"
– bibble triple
Mar 24 at 8:52
Follow this link - stackoverflow.com/questions/6817214/…
– Amir Khan
Mar 24 at 8:58
@vadian if i do that i cant acees the menu item from outside of that function
– bibble triple
Mar 24 at 9:06
try to remove all menu items before adding new items.
– Amir Khan
Mar 24 at 9:07
|
show 1 more comment
where is yourdockMenu
defined?
– Amir Khan
Mar 24 at 8:48
@AmirKhan outside of myclass as "let dockMenu = NSMenu()"
– bibble triple
Mar 24 at 8:52
Follow this link - stackoverflow.com/questions/6817214/…
– Amir Khan
Mar 24 at 8:58
@vadian if i do that i cant acees the menu item from outside of that function
– bibble triple
Mar 24 at 9:06
try to remove all menu items before adding new items.
– Amir Khan
Mar 24 at 9:07
where is your
dockMenu
defined?– Amir Khan
Mar 24 at 8:48
where is your
dockMenu
defined?– Amir Khan
Mar 24 at 8:48
@AmirKhan outside of myclass as "let dockMenu = NSMenu()"
– bibble triple
Mar 24 at 8:52
@AmirKhan outside of myclass as "let dockMenu = NSMenu()"
– bibble triple
Mar 24 at 8:52
Follow this link - stackoverflow.com/questions/6817214/…
– Amir Khan
Mar 24 at 8:58
Follow this link - stackoverflow.com/questions/6817214/…
– Amir Khan
Mar 24 at 8:58
@vadian if i do that i cant acees the menu item from outside of that function
– bibble triple
Mar 24 at 9:06
@vadian if i do that i cant acees the menu item from outside of that function
– bibble triple
Mar 24 at 9:06
try to remove all menu items before adding new items.
– Amir Khan
Mar 24 at 9:07
try to remove all menu items before adding new items.
– Amir Khan
Mar 24 at 9:07
|
show 1 more comment
1 Answer
1
active
oldest
votes
You have to create the NSMenu
inside the method
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
let dockMenu = NSMenu()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
or remove the items
let dockMenu = NSMenu()
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.removeAllItems()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
However I would declare it in Interface Builder and use an outlet.
if i put the let var in that function then i cant acess the menu items from outside of it
– bibble triple
Mar 24 at 9:16
See my update and please read my last sentence.
– vadian
Mar 24 at 9:16
1
@AmirKhanlet
is correct asNSMenu
is reference type
– vadian
Mar 24 at 9:20
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322034%2fadding-menu-items-to-the-right-click-app-menu-in-the-dock-casues-them-to-be-re-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have to create the NSMenu
inside the method
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
let dockMenu = NSMenu()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
or remove the items
let dockMenu = NSMenu()
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.removeAllItems()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
However I would declare it in Interface Builder and use an outlet.
if i put the let var in that function then i cant acess the menu items from outside of it
– bibble triple
Mar 24 at 9:16
See my update and please read my last sentence.
– vadian
Mar 24 at 9:16
1
@AmirKhanlet
is correct asNSMenu
is reference type
– vadian
Mar 24 at 9:20
add a comment |
You have to create the NSMenu
inside the method
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
let dockMenu = NSMenu()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
or remove the items
let dockMenu = NSMenu()
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.removeAllItems()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
However I would declare it in Interface Builder and use an outlet.
if i put the let var in that function then i cant acess the menu items from outside of it
– bibble triple
Mar 24 at 9:16
See my update and please read my last sentence.
– vadian
Mar 24 at 9:16
1
@AmirKhanlet
is correct asNSMenu
is reference type
– vadian
Mar 24 at 9:20
add a comment |
You have to create the NSMenu
inside the method
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
let dockMenu = NSMenu()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
or remove the items
let dockMenu = NSMenu()
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.removeAllItems()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
However I would declare it in Interface Builder and use an outlet.
You have to create the NSMenu
inside the method
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
let dockMenu = NSMenu()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
or remove the items
let dockMenu = NSMenu()
func applicationDockMenu(_ sender: NSApplication) -> NSMenu?
dockMenu.removeAllItems()
dockMenu.addItem(withTitle: "test1", action: nil, keyEquivalent: "")
return dockMenu
However I would declare it in Interface Builder and use an outlet.
edited Mar 24 at 9:15
answered Mar 24 at 9:02
vadianvadian
161k17175196
161k17175196
if i put the let var in that function then i cant acess the menu items from outside of it
– bibble triple
Mar 24 at 9:16
See my update and please read my last sentence.
– vadian
Mar 24 at 9:16
1
@AmirKhanlet
is correct asNSMenu
is reference type
– vadian
Mar 24 at 9:20
add a comment |
if i put the let var in that function then i cant acess the menu items from outside of it
– bibble triple
Mar 24 at 9:16
See my update and please read my last sentence.
– vadian
Mar 24 at 9:16
1
@AmirKhanlet
is correct asNSMenu
is reference type
– vadian
Mar 24 at 9:20
if i put the let var in that function then i cant acess the menu items from outside of it
– bibble triple
Mar 24 at 9:16
if i put the let var in that function then i cant acess the menu items from outside of it
– bibble triple
Mar 24 at 9:16
See my update and please read my last sentence.
– vadian
Mar 24 at 9:16
See my update and please read my last sentence.
– vadian
Mar 24 at 9:16
1
1
@AmirKhan
let
is correct as NSMenu
is reference type– vadian
Mar 24 at 9:20
@AmirKhan
let
is correct as NSMenu
is reference type– vadian
Mar 24 at 9:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322034%2fadding-menu-items-to-the-right-click-app-menu-in-the-dock-casues-them-to-be-re-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
where is your
dockMenu
defined?– Amir Khan
Mar 24 at 8:48
@AmirKhan outside of myclass as "let dockMenu = NSMenu()"
– bibble triple
Mar 24 at 8:52
Follow this link - stackoverflow.com/questions/6817214/…
– Amir Khan
Mar 24 at 8:58
@vadian if i do that i cant acees the menu item from outside of that function
– bibble triple
Mar 24 at 9:06
try to remove all menu items before adding new items.
– Amir Khan
Mar 24 at 9:07