objective c - how to temporarily hide the main menu (NSMenu)? -


i'm trying implement feature password protect cocoa app. in appdelegate, if password entered correctly on window, i'll bring main app window calling nsapp runmodelforwindow method.

it works fine, except, in preferences allow user change password. means in order prevent hacking users, i'll have hide main menu, until password entered correctly.

i don't want remove menu items using removeitematindex or programmatically set target action call method bring preference window. instead, temporary hide [nsapp mainmenu]. searched , can't seem find method, sethidden:yes in order hide it.

i have tried [[nsapp mainmenu] canceltracking] doesn't job

is there easy way this?

you can use -setpresentationoptions: method on nsapp hide , show many parts of standard os ui, including menu bar , dock. note must hide both menu bar , dock together:

/* hide */ [nsapp setpresentationoptions:[nsapp presentationoptions] |                                nsapplicationpresentationhidemenubar |                                nsapplicationpresentationhidedock];  /* show */ [nsapp setpresentationoptions:[nsapp presentationoptions] ^                                nsapplicationpresentationhidemenubar ^                                 nsapplicationpresentationhidedock]; 

this pretty disruptive ui experience though. consider disabling menu items or ui elements don't want user access while password dialog on screen.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -