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;








0















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



enter image description here










share|improve this question
























  • 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

















0















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



enter image description here










share|improve this question
























  • 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













0












0








0








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



enter image description here










share|improve this question
















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



enter image description here







swift macos cocoa






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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

















  • 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
















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












1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer

























  • 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





    @AmirKhan let is correct as NSMenu is reference type

    – vadian
    Mar 24 at 9:20











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
);



);













draft saved

draft discarded


















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









0














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.






share|improve this answer

























  • 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





    @AmirKhan let is correct as NSMenu is reference type

    – vadian
    Mar 24 at 9:20















0














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.






share|improve this answer

























  • 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





    @AmirKhan let is correct as NSMenu is reference type

    – vadian
    Mar 24 at 9:20













0












0








0







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








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





    @AmirKhan let is correct as NSMenu 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











  • See my update and please read my last sentence.

    – vadian
    Mar 24 at 9:16






  • 1





    @AmirKhan let is correct as NSMenu 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현