summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.MacOS/Extensions/NSButtonExtensions.cs
blob: d37f1a3d689a6192d61c7b514d1be0fb462a1233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
´╗┐using System;
using AppKit;

namespace Xamarin.Forms.Platform.MacOS
{
	public static class NSButtonExtensions
	{
		public static NSButton CreateButton(string text, Action activate = null)
		{
			return CreateButton(text, null, activate);
		}

		public static NSButton CreateButton(string text, NSImage image = null, Action activate = null)
		{
			var btn = new NSButton { Title = text };
			btn.BezelStyle = NSBezelStyle.TexturedRounded;

			if (image != null)
				btn.Image = image;
			if (activate != null)
				btn.Activated += (sender, e) => activate();
			return btn;
		}
	}
}