]> O.S.I.I.S - jp/crow.git/commitdiff
mouse repeat
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 5 May 2020 13:46:18 +0000 (15:46 +0200)
committerj-p <jp_bruyere@hotmail.com>
Sat, 9 May 2020 22:50:02 +0000 (00:50 +0200)
Crow/src/Interface.cs
Directory.Build.props

index bc26e8c6d9dbd4a71cbac0dc08fd3f9e93b6d5f1..6d795f664523f8958aad77cb6ea6a21196d1dcb9 100644 (file)
@@ -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) {
index 4ef561d42c5baa7a4c5f89bc73b3672050248701..de22b45a7fcff04b6b24fbd026b66a53c6cb998c 100644 (file)
@@ -7,7 +7,7 @@
                <Authors>Jean-Philippe Bruyère</Authors>           
                <LangVersion>7.2</LangVersion>
                
-               <CrowVersion>0.8.9</CrowVersion>
+               <CrowVersion>0.8.11</CrowVersion>
                <CrowPackageVersion>$(CrowVersion)-beta</CrowPackageVersion>
                <CrowStbSharp>true</CrowStbSharp>
        </PropertyGroup>