Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AutoClosePopOver.cs « Custom « Controls « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f516c138158b093c81f2cbcd7f510c9e691e31a3 (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
26
27
28
29
30
31
32
33
34
35
using System;
using AppKit;
using Foundation;

namespace Xamarin.PropertyEditing.Mac
{
	internal class AutoClosePopOver : NSPopover
	{
		private IHostResourceProvider hostResources;

		public bool CloseOnEnter { get; internal set; }

		public AutoClosePopOver (IHostResourceProvider hostResources, NSAppearance effectiveAppearance)
		{
			if (hostResources == null)
				throw new ArgumentNullException (nameof (hostResources));

			this.hostResources = hostResources;

			Behavior = NSPopoverBehavior.Semitransient;
			Delegate = new PopoverFocusRestoreDelegate ();
			CloseOnEnter = true;

			Appearance = this.hostResources.GetVibrantAppearance (effectiveAppearance);
		}

		public override void KeyUp (NSEvent theEvent)
		{
			// If Enter Kit, close the pop-up
			if (theEvent.KeyCode == 36 && CloseOnEnter) {
				this.Close ();
			}
		}
	}
}