From: Jean-Philippe Bruyère Date: Tue, 5 May 2020 13:46:18 +0000 (+0200) Subject: mouse repeat X-Git-Tag: v0.9.5-beta~122 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=f9b4b317e677187d49ac706aa0cc12571849d660;p=jp%2Fcrow.git mouse repeat --- diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index bc26e8c6..6d795f66 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -57,7 +57,7 @@ namespace Crow /** GLFW window native pointer and current native handle for mouse cursor */ IntPtr hWin, currentCursor; - protected virtual void InitSurface () + void initSurface () { Glfw3.Init (); @@ -108,22 +108,20 @@ namespace Crow windows [window].OnMouseMove ((int)xPosition, (int)yPosition); }; static MouseButtonDelegate HandleMouseButtonDelegate = (IntPtr window, MouseButton button, InputAction action, Modifier mods) => { - if (action == InputAction.Press) { - windows [window].OnMouseButtonDown (button); - } else { + if (action == InputAction.Release) windows [window].OnMouseButtonUp (button); - } + else//press and repeat + windows [window].OnMouseButtonDown (button); + }; static ScrollDelegate HandleScrollDelegate = (IntPtr window, double xOffset, double yOffset) => { windows [window].OnMouseWheelChanged ((int)yOffset); }; static KeyDelegate HandleKeyDelegate = (IntPtr window, Key key, int scanCode, InputAction action, Modifier modifiers) => { - - if (action == InputAction.Press || action == InputAction.Repeat) { - windows [window].OnKeyDown (key); - } else { + if (action == InputAction.Release) windows [window].OnKeyUp (key); - } + else + windows [window].OnKeyDown (key); }; static CharDelegate HandleCharDelegate = (IntPtr window, CodePoint codepoint) => { windows [window].OnKeyPress (codepoint.ToChar()); @@ -163,12 +161,17 @@ namespace Crow FontRenderingOptions.HintStyle = HintStyle.Full; FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default; } - public Interface(int width=800, int height=600, bool startUIThread = true) { + public Interface (int width, int height, IntPtr glfwWindowHandle) : this(width, height, false, false) + { + hWin = glfwWindowHandle; + } + public Interface(int width=800, int height=600, bool startUIThread = true, bool createSurface = true) { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CurrentInterface = this; clientRectangle = new Rectangle (0, 0, width, height); - InitSurface (); + if (createSurface) + initSurface (); if (startUIThread) { Thread t = new Thread (InterfaceThread) { diff --git a/Directory.Build.props b/Directory.Build.props index 4ef561d4..de22b45a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,7 +7,7 @@ Jean-Philippe Bruyère 7.2 - 0.8.9 + 0.8.11 $(CrowVersion)-beta true