diff options
author | Seungkeun Lee <sngn.lee@samsung.com> | 2017-05-12 15:11:46 +0900 |
---|---|---|
committer | Seungkeun Lee <sngn.lee@samsung.com> | 2017-05-15 13:57:35 +0900 |
commit | ccbcef9361801816269881be3556d66a89e0b96d (patch) | |
tree | 60ec93a692d55504aa53c66e1983dee85be71f5c | |
parent | 267230a4a801adab807b41eeb0b99e5eae2d0815 (diff) | |
download | elm-sharp-ccbcef9361801816269881be3556d66a89e0b96d.tar.gz elm-sharp-ccbcef9361801816269881be3556d66a89e0b96d.tar.bz2 elm-sharp-ccbcef9361801816269881be3556d66a89e0b96d.zip |
Add BackButtonPressed/MoreButtonPressed event on EvasObject
- Using eext_object_event_callback_add
- It automatically routing Button event depend on Z-order
Change-Id: I29759e6cdad3d176b5f493f54400a3fd64d33b40
-rw-r--r-- | ElmSharp.Test/TC/PopupTest1.cs | 7 | ||||
-rw-r--r-- | ElmSharp.Test/TestRunner.cs | 27 | ||||
-rw-r--r-- | ElmSharp/ElmSharp.csproj | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | ElmSharp/ElmSharp/EvasObject.cs | 56 | ||||
-rw-r--r-- | ElmSharp/Interop/Interop.Eext.Event.cs | 38 | ||||
-rw-r--r-- | packaging/elm-sharp.spec | 2 |
6 files changed, 113 insertions, 18 deletions
diff --git a/ElmSharp.Test/TC/PopupTest1.cs b/ElmSharp.Test/TC/PopupTest1.cs index c3e0a5d..90eda9c 100644 --- a/ElmSharp.Test/TC/PopupTest1.cs +++ b/ElmSharp.Test/TC/PopupTest1.cs @@ -62,13 +62,18 @@ namespace ElmSharp.Test popup.TimedOut += (s, e) => { Console.WriteLine("Popup time out"); - popup.Show(); }; popup.Append("Label1"); popup.Append("Label2"); popup.Append("Label3"); + popup.BackButtonPressed += (s, e) => + { + Console.WriteLine("!!! BackButtonPressed Event on Popup!!"); + popup.Hide(); + }; + btn.Clicked += (s, e) => { popup.Show(); diff --git a/ElmSharp.Test/TestRunner.cs b/ElmSharp.Test/TestRunner.cs index ebdab32..3ee156b 100644 --- a/ElmSharp.Test/TestRunner.cs +++ b/ElmSharp.Test/TestRunner.cs @@ -107,27 +107,19 @@ namespace ElmSharp.Test window.Show(); if (isSecond) { - window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, true); - window.KeyUp += (s, e) => + window.BackButtonPressed += (s, e) => { - if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName) - { - window.Hide(); - window.Unrealize(); - GC.Collect(); - GC.WaitForPendingFinalizers(); - } + window.Hide(); + window.Unrealize(); + GC.Collect(); + GC.WaitForPendingFinalizers(); }; } else { - window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, false); - window.KeyUp += (s, e) => + window.BackButtonPressed += (s, e) => { - if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName) - { - UIExit(); - } + UIExit(); }; } return window; @@ -147,7 +139,10 @@ namespace ElmSharp.Test WeightY = 1, }; box.Show(); - conformant.SetContent(box); + var bg = new Background(_firstPageWindow); + bg.Color = Color.White; + bg.SetContent(box); + conformant.SetContent(bg); GenList list = new GenList(_firstPageWindow) { diff --git a/ElmSharp/ElmSharp.csproj b/ElmSharp/ElmSharp.csproj index 8a90bfb..1379553 100644 --- a/ElmSharp/ElmSharp.csproj +++ b/ElmSharp/ElmSharp.csproj @@ -51,6 +51,7 @@ <Compile Include="ElmSharp\IAccessibleObject.cs" /> <Compile Include="ElmSharp\ItemObjectExtension.cs" /> <Compile Include="ElmSharp\ReadingInfoType.cs" /> + <Compile Include="Interop\Interop.Eext.Event.cs" /> <Compile Include="Interop\Interop.Elementary.Accessibility.cs" /> <Compile Include="ElmSharp\Background.cs" /> <Compile Include="ElmSharp\Box.cs" /> diff --git a/ElmSharp/ElmSharp/EvasObject.cs b/ElmSharp/ElmSharp/EvasObject.cs index f885c0b..a927914 100755..100644 --- a/ElmSharp/ElmSharp/EvasObject.cs +++ b/ElmSharp/ElmSharp/EvasObject.cs @@ -26,6 +26,11 @@ namespace ElmSharp public abstract class EvasObject { private IntPtr _realHandle = IntPtr.Zero; + private event EventHandler _backButtonPressed; + private event EventHandler _moreButtonPressed; + private Interop.Eext.EextEventCallback _backButtonHandler; + private Interop.Eext.EextEventCallback _moreButtonHandler; + internal IntPtr Handle { get; set; } internal EvasObject Parent { get; set; } internal IntPtr RealHandle @@ -65,6 +70,9 @@ namespace ElmSharp /// </summary> protected EvasObject() { + _backButtonHandler = new Interop.Eext.EextEventCallback((d, o, i) => { _backButtonPressed?.Invoke(this, EventArgs.Empty); }); + _moreButtonHandler = new Interop.Eext.EextEventCallback((d, o, i) => { _moreButtonPressed?.Invoke(this, EventArgs.Empty); }); + OnInstantiated(); } @@ -88,6 +96,54 @@ namespace ElmSharp /// KeyDown will be triggered when key is preesd down /// </summary> public event EventHandler<EvasKeyEventArgs> KeyDown; + + /// <summary> + /// BackButtonPressed will be triggered when Back button is pressed + /// </summary> + public event EventHandler BackButtonPressed + { + add + { + if (_backButtonPressed == null) + { + Interop.Eext.eext_object_event_callback_add(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_BACK, _backButtonHandler, IntPtr.Zero); + } + _backButtonPressed += value; + } + remove + { + _backButtonPressed -= value; + if (_backButtonPressed == null) + { + Interop.Eext.eext_object_event_callback_del(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_BACK, _backButtonHandler); + } + } + } + + /// <summary> + /// MoreButtonPressed will be triggered when More button is pressed + /// </summary> + public event EventHandler MoreButtonPressed + { + add + { + if (_moreButtonPressed == null) + { + Interop.Eext.eext_object_event_callback_add(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_MORE, _moreButtonHandler, IntPtr.Zero); + } + _moreButtonPressed += value; + } + remove + { + _moreButtonPressed -= value; + if (_moreButtonPressed == null) + { + Interop.Eext.eext_object_event_callback_del(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_MORE, _moreButtonHandler); + } + } + } + + /// <summary> /// Moved will be triggered when widght is moved /// </summary> diff --git a/ElmSharp/Interop/Interop.Eext.Event.cs b/ElmSharp/Interop/Interop.Eext.Event.cs new file mode 100644 index 0000000..02420dc --- /dev/null +++ b/ElmSharp/Interop/Interop.Eext.Event.cs @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Eext + { + public enum EextCallbackType + { + EEXT_CALLBACK_BACK, // H/W Back Key Event + EEXT_CALLBACK_MORE, // H/W More Key Event + } + internal delegate void EextEventCallback(IntPtr data, IntPtr obj, IntPtr info); + + [DllImport(Libraries.Eext)] + internal static extern void eext_object_event_callback_add(IntPtr obj, EextCallbackType type, EextEventCallback callback, IntPtr data); + + + [DllImport(Libraries.Eext)] + internal static extern void eext_object_event_callback_del(IntPtr obj, EextCallbackType type, EextEventCallback callback); + } +} diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 52bb918..8970287 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -1,4 +1,4 @@ -%define DEV_VERSION beta-023 +%define DEV_VERSION beta-024 Name: elm-sharp Summary: C# Binding for Elementary |