blob: 0f30939ef70018e2d14707007953889c13b5e83c (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
using System;
using AppKit;
namespace Xamarin.PropertyEditing.Mac
{
internal class ProxyResponderButton : NSButton
{
public RowProxyResponder ProxyResponder { get; set; }
public override void KeyDown (NSEvent theEvent)
{
switch (theEvent.KeyCode) {
case (int)NSKey.Tab:
if (ProxyResponder != null) {
if (theEvent.ModifierFlags.HasFlag(NSEventModifierMask.ShiftKeyMask)) {
ProxyResponder.PreviousResponder ();
} else {
ProxyResponder.NextResponder ();
}
}
return;
}
base.KeyDown (theEvent);
}
}
internal class FocusableBooleanButton : ProxyResponderButton
{
public override bool CanBecomeKeyView { get { return Enabled; } }
public FocusableBooleanButton ()
{
AllowsExpansionToolTips = true;
AllowsMixedState = true;
Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
Cell.UsesSingleLineMode = true;
ControlSize = NSControlSize.Small;
Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small));
Title = string.Empty;
TranslatesAutoresizingMaskIntoConstraints = false;
SetButtonType (NSButtonType.Switch);
}
public override bool BecomeFirstResponder ()
{
var willBecomeFirstResponder = base.BecomeFirstResponder ();
if (willBecomeFirstResponder) {
ScrollRectToVisible (Bounds);
}
return willBecomeFirstResponder;
}
}
}
|