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

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2013-10-03 12:10:36 +0400
committerLluis Sanchez <lluis@xamarin.com>2013-10-03 12:10:36 +0400
commit03881a0972089a52776fdfa21125a25be3336b9d (patch)
tree2eccd38ba8cbae39f5537e811ffedd5a7b166337 /Xwt.Mac
parent2731d26aadf684e690c63389007c615f7eb70843 (diff)
[Mac] Implement KeyboardHandler
Diffstat (limited to 'Xwt.Mac')
-rw-r--r--Xwt.Mac/Xwt.Mac.csproj1
-rw-r--r--Xwt.Mac/Xwt.Mac/MacEngine.cs1
-rw-r--r--Xwt.Mac/Xwt.Mac/MacKeyboardHandler.cs41
-rw-r--r--Xwt.Mac/Xwt.Mac/Util.cs14
4 files changed, 57 insertions, 0 deletions
diff --git a/Xwt.Mac/Xwt.Mac.csproj b/Xwt.Mac/Xwt.Mac.csproj
index b7cf2b87..c7fa2149 100644
--- a/Xwt.Mac/Xwt.Mac.csproj
+++ b/Xwt.Mac/Xwt.Mac.csproj
@@ -123,6 +123,7 @@
<Compile Include="Xwt.Mac\SliderBackend.cs" />
<Compile Include="Xwt.Mac.CellViews\CheckBoxTableCell.cs" />
<Compile Include="Xwt.Mac\EmbedNativeWidgetBackend.cs" />
+ <Compile Include="Xwt.Mac\MacKeyboardHandler.cs" />
</ItemGroup>
<Import Project="..\BuildHelpers.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
diff --git a/Xwt.Mac/Xwt.Mac/MacEngine.cs b/Xwt.Mac/Xwt.Mac/MacEngine.cs
index de6b372b..89fca49c 100644
--- a/Xwt.Mac/Xwt.Mac/MacEngine.cs
+++ b/Xwt.Mac/Xwt.Mac/MacEngine.cs
@@ -120,6 +120,7 @@ namespace Xwt.Mac
RegisterBackend <Xwt.Backends.IDatePickerBackend, DatePickerBackend> ();
RegisterBackend <Xwt.Backends.ISliderBackend, SliderBackend> ();
RegisterBackend <Xwt.Backends.IEmbeddedWidgetBackend, EmbedNativeWidgetBackend> ();
+ RegisterBackend <Xwt.Backends.KeyboardHandler, MacKeyboardHandler> ();
}
public override void RunApplication ()
diff --git a/Xwt.Mac/Xwt.Mac/MacKeyboardHandler.cs b/Xwt.Mac/Xwt.Mac/MacKeyboardHandler.cs
new file mode 100644
index 00000000..3e056825
--- /dev/null
+++ b/Xwt.Mac/Xwt.Mac/MacKeyboardHandler.cs
@@ -0,0 +1,41 @@
+//
+// MacKeyboardHandler.cs
+//
+// Author:
+// Lluis Sanchez <lluis@xamarin.com>
+//
+// Copyright (c) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Xwt.Backends;
+using MonoMac.AppKit;
+
+namespace Xwt.Mac
+{
+ public class MacKeyboardHandler: KeyboardHandler
+ {
+ public override ModifierKeys CurrentModifiers {
+ get {
+ return NSEvent.CurrentModifierFlags.ToXwtValue ();
+ }
+ }
+ }
+}
+
diff --git a/Xwt.Mac/Xwt.Mac/Util.cs b/Xwt.Mac/Xwt.Mac/Util.cs
index 4a8258e7..02d706b4 100644
--- a/Xwt.Mac/Xwt.Mac/Util.cs
+++ b/Xwt.Mac/Xwt.Mac/Util.cs
@@ -389,6 +389,20 @@ namespace Xwt.Mac
throw new ArgumentOutOfRangeException ();
}
}
+
+ public static ModifierKeys ToXwtValue (this NSEventModifierMask e)
+ {
+ ModifierKeys m = ModifierKeys.None;
+ if (e.HasFlag (NSEventModifierMask.ControlKeyMask))
+ m |= ModifierKeys.Control;
+ if (e.HasFlag (NSEventModifierMask.AlternateKeyMask))
+ m |= ModifierKeys.Alt;
+ if (e.HasFlag (NSEventModifierMask.CommandKeyMask))
+ m |= ModifierKeys.Command;
+ if (e.HasFlag (NSEventModifierMask.ShiftKeyMask))
+ m |= ModifierKeys.Shift;
+ return m;
+ }
}
public interface ICopiableObject