From 060b89f24df61f71f281989ce81368dbefb47886 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 1 Sep 2020 20:47:10 +0200 Subject: [PATCH] widget focus, update glfw-net --- Crow/Crow.csproj | 2 +- Crow/src/IML/Instantiator.cs | 4 ++-- Crow/src/Interface.cs | 22 +++++++++++++--------- Crow/src/Mono.Cairo/Device.cs | 2 +- Crow/src/Widgets/TextBox.cs | 2 +- Crow/src/Widgets/Widget.cs | 7 ++++--- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 8a0b9434..481cb7b0 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -38,7 +38,7 @@ - + diff --git a/Crow/src/IML/Instantiator.cs b/Crow/src/IML/Instantiator.cs index 7bf27b28..7a4ca5a6 100644 --- a/Crow/src/IML/Instantiator.cs +++ b/Crow/src/IML/Instantiator.cs @@ -1319,8 +1319,8 @@ namespace Crow.IML { //value type for conversion CompilerServices.emitConvert (il, piSource.PropertyType); - if (!piSource.CanWrite) - throw new Exception ("Source member of bindind is read only:" + piSource.ToString()); + if (piSource.SetMethod == null) + throw new Exception ("Source member of bindind is read only:" + piSource.ToString ()); il.Emit (OpCodes.Callvirt, piSource.GetSetMethod ()); diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 520899fd..d11070f8 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -125,6 +125,17 @@ namespace Crow Cursor currentCursor; bool ownWindow; + protected void registerGlfwCallbacks () + { + windows.Add (hWin, this); + Glfw3.SetKeyCallback (hWin, HandleKeyDelegate); + Glfw3.SetMouseButtonPosCallback (hWin, HandleMouseButtonDelegate); + Glfw3.SetCursorPosCallback (hWin, HandleCursorPosDelegate); + Glfw3.SetScrollCallback (hWin, HandleScrollDelegate); + Glfw3.SetCharCallback (hWin, HandleCharDelegate); + Glfw3.SetWindowSizeCallback (hWin, HandleWindowSizeDelegate); + } + void initSurface () { Glfw3.Init (); @@ -138,12 +149,7 @@ namespace Crow throw new Exception ("[GLFW3] Unable to create vulkan Window"); ownWindow = true; - Glfw3.SetKeyCallback (hWin, HandleKeyDelegate); - Glfw3.SetMouseButtonPosCallback (hWin, HandleMouseButtonDelegate); - Glfw3.SetCursorPosCallback (hWin, HandleCursorPosDelegate); - Glfw3.SetScrollCallback (hWin, HandleScrollDelegate); - Glfw3.SetCharCallback (hWin, HandleCharDelegate); - Glfw3.SetWindowSizeCallback (hWin, HandleWindowSizeDelegate); + registerGlfwCallbacks (); switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: @@ -166,8 +172,6 @@ namespace Crow case PlatformID.WinCE: throw new PlatformNotSupportedException ("Unable to create cairo surface."); } - - windows.Add (hWin, this); } #region events delegates @@ -597,7 +601,7 @@ namespace Crow #region focus Widget _activeWidget; //button is pressed on widget Widget _hoverWidget; //mouse is over - Widget _focusedWidget; //has keyboard (or other perif) focus + internal Widget _focusedWidget; //has keyboard (or other perif) focus /// Widget is focused and button is down or another perif action is occuring /// , it can not lose focus while Active diff --git a/Crow/src/Mono.Cairo/Device.cs b/Crow/src/Mono.Cairo/Device.cs index dc9910cb..484264f0 100644 --- a/Crow/src/Mono.Cairo/Device.cs +++ b/Crow/src/Mono.Cairo/Device.cs @@ -64,7 +64,7 @@ namespace Crow.Cairo } public string Status { get { - return ""; //System.Runtime.InteropServices.Marshal.PtrToStringAuto(NativeMethods.cairo_status_to_string (NativeMethods.cairo_device_status (handle))); + return System.Runtime.InteropServices.Marshal.PtrToStringAuto(NativeMethods.cairo_status_to_string (NativeMethods.cairo_device_status (handle))); } } public void SetThreadAware (bool value){ diff --git a/Crow/src/Widgets/TextBox.cs b/Crow/src/Widgets/TextBox.cs index 06b2b2d9..31b513a6 100644 --- a/Crow/src/Widgets/TextBox.cs +++ b/Crow/src/Widgets/TextBox.cs @@ -18,7 +18,7 @@ namespace Crow [XmlIgnore]public override bool HasFocus //trigger update when lost focus to errase text beam { get => base.HasFocus; - internal set { + set { if (base.HasFocus == value) return; base.HasFocus = value; diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 04eadf8d..c060f954 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -701,14 +701,15 @@ namespace Crow /// [XmlIgnore]public virtual bool HasFocus { get { return hasFocus; } - internal set { + set { if (value == hasFocus) return; hasFocus = value; - if (hasFocus) + if (hasFocus) { + IFace.FocusedWidget = this; onFocused (this, null); - else + } else onUnfocused (this, null); NotifyValueChangedAuto (hasFocus); } -- 2.47.3