Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

How to manage the state of the menu items ?

$
0
0

I want to manage the state of a menu item
Let’s take the example “macmenu” provided by Xamarin

In app delegate.cs, the method:

    partial void phrasesDate (Foundation.NSObject sender) {

        if (textEditor == null) return;

    textEditor.Text += DateTime.Now.ToString("D");


I want to add
Sender.State = NSCellStateValue.On;


But of course this doesn’t work as “sender” is an NSObject and not an NSMenuItem.

So I modify the method to

partial void phrasesDate (NSMenuItem sender) {


But in this cas, I also have to modify the appdelegate.designer.cs.
[Action ("phrasesDate:")]

partial void phrasesDate (Foundation.NSObject sender);

To
[Action ("phrasesDate:")]

partial void phrasesDate (NSMenuItem sender);

Question: is there no other way to do this ?
Because, it’s not recommended to modify the “appdelegate.designer.cs”…

Thanks

Pit


Viewing all articles
Browse latest Browse all 1429

Trending Articles