private MouseFlags ProcessButtonClickedEvent(Curses.MouseEvent cev) { LastMouseButtonPressed = cev.ButtonState; var mf = GetButtonState(cev, true); mouseHandler(ProcessButtonState(cev, mf)); if (LastMouseButtonPressed != null && LastMouseButtonPressed == cev.ButtonState) { mf = GetButtonState(cev, false); mouseHandler(ProcessButtonState(cev, mf)); if (LastMouseButtonPressed != null && LastMouseButtonPressed == cev.ButtonState) { mf = (MouseFlags)cev.ButtonState; } } LastMouseButtonPressed = null; canWheeledDown = false; return(mf); }
MouseEvent ToDriverMouse(Curses.MouseEvent cev) { MouseFlags mouseFlag = MouseFlags.AllEvents; if (LastMouseButtonPressed != null && cev.ButtonState != Curses.Event.ReportMousePosition) { LastMouseButtonPressed = null; IsButtonPressed = false; } if ((cev.ButtonState == Curses.Event.Button1Clicked || cev.ButtonState == Curses.Event.Button2Clicked || cev.ButtonState == Curses.Event.Button3Clicked) && LastMouseButtonPressed == null) { IsButtonPressed = false; mouseFlag = ProcessButtonClickedEvent(cev, mouseFlag); } else if (((cev.ButtonState == Curses.Event.Button1Pressed || cev.ButtonState == Curses.Event.Button2Pressed || cev.ButtonState == Curses.Event.Button3Pressed) && LastMouseButtonPressed == null) || IsButtonPressed && cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = (MouseFlags)cev.ButtonState; if (cev.ButtonState != Curses.Event.ReportMousePosition) { LastMouseButtonPressed = cev.ButtonState; } IsButtonPressed = true; if (cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = (MouseFlags)LastMouseButtonPressed | MouseFlags.ReportMousePosition; point = new Point(); cancelButtonClicked = true; } else { point = new Point() { X = cev.X, Y = cev.Y }; } if ((mouseFlag & MouseFlags.ReportMousePosition) == 0) { Task.Run(async() => { while (IsButtonPressed && LastMouseButtonPressed != null) { await Task.Delay(200); var me = new MouseEvent() { X = cev.X, Y = cev.Y, Flags = mouseFlag }; var view = Application.wantContinuousButtonPressedView; if (view == null) { break; } if (IsButtonPressed && LastMouseButtonPressed != null && (mouseFlag & MouseFlags.ReportMousePosition) == 0) { mouseHandler(me); //mainLoop.Driver.Wakeup (); } } }); } } else if ((cev.ButtonState == Curses.Event.Button1Released || cev.ButtonState == Curses.Event.Button2Released || cev.ButtonState == Curses.Event.Button3Released)) { mouseFlag = ProcessButtonReleasedEvent(cev, mouseFlag); IsButtonPressed = false; } else if (cev.ButtonState == Curses.Event.Button4Pressed) { mouseFlag = MouseFlags.WheeledUp; } else if (cev.ButtonState == Curses.Event.ReportMousePosition && cev.X == point.X && cev.Y == point.Y) { mouseFlag = MouseFlags.WheeledDown; } else if (cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = MouseFlags.ReportMousePosition; } else { mouseFlag = (MouseFlags)cev.ButtonState; } point = new Point() { X = cev.X, Y = cev.Y }; if (cev.ID != 0) { mouseFlag = MouseFlags.WheeledDown; } return(new MouseEvent() { X = cev.X, Y = cev.Y, //Flags = (MouseFlags)cev.ButtonState Flags = mouseFlag }); }
MouseEvent ToDriverMouse(Curses.MouseEvent cev) { MouseFlags mouseFlag = MouseFlags.AllEvents; if (LastMouseButtonPressed != null && cev.ButtonState != Curses.Event.ReportMousePosition) { LastMouseButtonPressed = null; IsButtonPressed = false; } if ((cev.ButtonState == Curses.Event.Button1Clicked || cev.ButtonState == Curses.Event.Button2Clicked || cev.ButtonState == Curses.Event.Button3Clicked) && LastMouseButtonPressed == null) { IsButtonPressed = false; mouseFlag = ProcessButtonClickedEvent(cev); } else if (((cev.ButtonState == Curses.Event.Button1Pressed || cev.ButtonState == Curses.Event.Button2Pressed || cev.ButtonState == Curses.Event.Button3Pressed) && LastMouseButtonPressed == null) || IsButtonPressed && cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = MapCursesButton(cev.ButtonState); if (cev.ButtonState != Curses.Event.ReportMousePosition) { LastMouseButtonPressed = cev.ButtonState; } IsButtonPressed = true; isReportMousePosition = false; if (cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = MapCursesButton((Curses.Event)LastMouseButtonPressed) | MouseFlags.ReportMousePosition; point = new Point(); //cancelButtonClicked = true; } else { point = new Point() { X = cev.X, Y = cev.Y }; } if ((mouseFlag & MouseFlags.ReportMousePosition) == 0) { ProcessContinuousButtonPressedAsync(cev, mouseFlag).ConfigureAwait(false); } } else if ((cev.ButtonState == Curses.Event.Button1Released || cev.ButtonState == Curses.Event.Button2Released || cev.ButtonState == Curses.Event.Button3Released)) { mouseFlag = ProcessButtonReleasedEvent(cev); IsButtonPressed = false; } else if (cev.ButtonState == Curses.Event.ButtonWheeledUp) { mouseFlag = MouseFlags.WheeledUp; } else if (cev.ButtonState == Curses.Event.ButtonWheeledDown) { mouseFlag = MouseFlags.WheeledDown; } else if ((cev.ButtonState & (Curses.Event.ButtonWheeledUp & Curses.Event.ButtonShift)) != 0) { mouseFlag = MouseFlags.WheeledLeft; } else if ((cev.ButtonState & (Curses.Event.ButtonWheeledDown & Curses.Event.ButtonShift)) != 0) { mouseFlag = MouseFlags.WheeledRight; } else if (cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = MouseFlags.ReportMousePosition; isReportMousePosition = true; } else { mouseFlag = 0; var eFlags = cev.ButtonState; foreach (Enum value in Enum.GetValues(eFlags.GetType())) { if (eFlags.HasFlag(value)) { mouseFlag |= MapCursesButton((Curses.Event)value); } } } mouseFlag = SetControlKeyStates(cev, mouseFlag); point = new Point() { X = cev.X, Y = cev.Y }; return(new MouseEvent() { X = cev.X, Y = cev.Y, //Flags = MapCursesButton (cev.ButtonState) Flags = mouseFlag }); }
MouseEvent ToDriverMouse(Curses.MouseEvent cev) { MouseFlags mouseFlag = MouseFlags.AllEvents; if (LastMouseButtonPressed != null && cev.ButtonState != Curses.Event.ReportMousePosition) { LastMouseButtonPressed = null; IsButtonPressed = false; } if ((cev.ButtonState == Curses.Event.Button1Clicked || cev.ButtonState == Curses.Event.Button2Clicked || cev.ButtonState == Curses.Event.Button3Clicked) && LastMouseButtonPressed == null) { IsButtonPressed = false; mouseFlag = ProcessButtonClickedEvent(cev); } else if (((cev.ButtonState == Curses.Event.Button1Pressed || cev.ButtonState == Curses.Event.Button2Pressed || cev.ButtonState == Curses.Event.Button3Pressed) && LastMouseButtonPressed == null) || IsButtonPressed && cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = MapCursesButton(cev.ButtonState); if (cev.ButtonState != Curses.Event.ReportMousePosition) { LastMouseButtonPressed = cev.ButtonState; } IsButtonPressed = true; isReportMousePosition = false; if (cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = MapCursesButton((Curses.Event)LastMouseButtonPressed) | MouseFlags.ReportMousePosition; point = new Point(); //cancelButtonClicked = true; } else { point = new Point() { X = cev.X, Y = cev.Y }; } if ((mouseFlag & MouseFlags.ReportMousePosition) == 0) { Task.Run(async() => { while (IsButtonPressed && LastMouseButtonPressed != null) { await Task.Delay(100); var me = new MouseEvent() { X = cev.X, Y = cev.Y, Flags = mouseFlag }; var view = Application.wantContinuousButtonPressedView; if (view == null) { break; } if (IsButtonPressed && LastMouseButtonPressed != null && (mouseFlag & MouseFlags.ReportMousePosition) == 0) { mouseHandler(me); //mainLoop.Driver.Wakeup (); } } }); } } else if ((cev.ButtonState == Curses.Event.Button1Released || cev.ButtonState == Curses.Event.Button2Released || cev.ButtonState == Curses.Event.Button3Released)) { mouseFlag = ProcessButtonReleasedEvent(cev); IsButtonPressed = false; } else if (cev.ButtonState == Curses.Event.ButtonWheeledUp) { mouseFlag = MouseFlags.WheeledUp; } else if (cev.ButtonState == Curses.Event.ButtonWheeledDown) { mouseFlag = MouseFlags.WheeledDown; } else if ((cev.ButtonState & (Curses.Event.ButtonWheeledUp & Curses.Event.ButtonShift)) != 0) { mouseFlag = MouseFlags.WheeledLeft; } else if ((cev.ButtonState & (Curses.Event.ButtonWheeledDown & Curses.Event.ButtonShift)) != 0) { mouseFlag = MouseFlags.WheeledRight; } else if (cev.ButtonState == Curses.Event.ReportMousePosition) { mouseFlag = MouseFlags.ReportMousePosition; isReportMousePosition = true; } else { mouseFlag = 0; var eFlags = cev.ButtonState; foreach (Enum value in Enum.GetValues(eFlags.GetType())) { if (eFlags.HasFlag(value)) { mouseFlag |= MapCursesButton((Curses.Event)value); } } } mouseFlag = SetControlKeyStates(cev, mouseFlag); point = new Point() { X = cev.X, Y = cev.Y }; return(new MouseEvent() { X = cev.X, Y = cev.Y, //Flags = MapCursesButton (cev.ButtonState) Flags = mouseFlag }); }