Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit 6585cc3

Browse files
authored
Merge pull request #502 from xamarin/focusable-combobox
[Mac] Creates a new focusable ComboBox with readonly modifier
2 parents 0120038 + e5345bb commit 6585cc3

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Foundation;
2+
using AppKit;
3+
4+
namespace Xamarin.PropertyEditing.Mac
5+
{
6+
class FocusableComboBox : NSComboBox
7+
{
8+
public override bool ShouldBeginEditing (NSText textObject)
9+
{
10+
textObject.Delegate = new FocusableComboBoxDelegate ();
11+
return false;
12+
}
13+
14+
public override void DidBeginEditing (NSNotification notification)
15+
{
16+
base.DidBeginEditing (notification);
17+
}
18+
19+
class FocusableComboBoxDelegate : NSTextDelegate
20+
{
21+
public override bool TextShouldEndEditing (NSText textObject)
22+
{
23+
return false;
24+
}
25+
26+
public override bool TextShouldBeginEditing (NSText textObject)
27+
{
28+
return false;
29+
}
30+
}
31+
}
32+
}

Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ public PredefinedValuesEditor (IHostResourceProvider hostResources)
2020
{
2121
base.TranslatesAutoresizingMaskIntoConstraints = false;
2222

23-
this.comboBox = new NSComboBox {
23+
this.comboBox = new FocusableComboBox {
2424
TranslatesAutoresizingMaskIntoConstraints = false,
2525
BackgroundColor = NSColor.Clear,
2626
StringValue = String.Empty,
2727
ControlSize = NSControlSize.Small,
28-
Editable = false,
2928
Font = NSFont.FromFontName(DefaultFontName, DefaultFontSize),
3029
};
3130

Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
<Compile Include="HostResourceProvider.cs" />
145145
<Compile Include="Controls\Custom\DynamicFillBox.cs" />
146146
<Compile Include="Controls\Custom\TabButton.cs" />
147+
<Compile Include="Controls\Custom\FocusableComboBox.cs" />
147148
</ItemGroup>
148149
<ItemGroup>
149150
<Folder Include="Controls\" />

0 commit comments

Comments
 (0)