ProcessMouse() public method

public ProcessMouse ( Curses ev ) : void
ev Curses
return void
Esempio n. 1
0
        static void ProcessChar(Container container)
        {
            int ch = Curses.getch ();

            if ((ch == -1) || (ch == Curses.KeyResize)){
                if (Curses.CheckWinChange ()){
                    EmptyContainer.Clear ();
                    foreach (Container c in toplevels)
                        c.SizeChanged ();
                    Refresh ();
                }
                return;
            }

            if (ch == Curses.KeyMouse){
                Curses.MouseEvent ev;

                Curses.console_sharp_getmouse (out ev);
                container.ProcessMouse (ev);
                return;
            }

            if (ch == 27){
                Curses.timeout (100);
                int k = Curses.getch ();
                if (k != Curses.ERR && k != 27)
                    ch = Curses.KeyAlt | k;
                Curses.timeout (-1);
            }

            if (container.ProcessHotKey (ch))
                return;

            if (container.ProcessKey (ch))
                return;

            if (container.ProcessColdKey (ch))
                return;

            // Control-c, quit the current operation.
            if (ch == 3){
                container.Running = false;
                return;
            }

            // Control-z, suspend execution, then repaint.
            if (ch == 26){
                Curses.console_sharp_sendsigtstp ();
                Window.Standard.redrawwin ();
                Curses.refresh ();
            }

            //
            // Focus handling
            //
            if (ch == 9 || ch == Curses.KeyDown || ch == Curses.KeyRight){
                if (!container.FocusNext ())
                    container.FocusNext ();
                Curses.refresh ();
            } else if (ch == Curses.KeyUp || ch == Curses.KeyLeft){
                if (!container.FocusPrev ())
                    container.FocusPrev ();
                Curses.refresh ();
            }
        }
Esempio n. 2
0
        /// <summary>
        ///   Runs the main loop on the given container.
        /// </summary>
        /// <remarks>
        ///   This method is used to start processing events
        ///   for the main application, but it is also used to
        ///   run modal dialog boxes.
        /// </remarks>
        public static void Run(Container container)
        {
            Init (false);

            Curses.timeout (-1);
            if (toplevels.Count == 0)
                InitApp ();

            toplevels.Add (container);

            container.Prepare ();
            container.SizeChanged ();
            container.FocusFirst ();
            Redraw (container);
            container.PositionCursor ();

            int ch;
            Curses.timeout (Timeout);

            for (container.Running = true; container.Running; ){
                ch = Curses.getch ();

                if (Iteration != null)
                    Iteration (null, EventArgs.Empty);

                if (ch == -1){
                    if (Curses.CheckWinChange ()){
                        EmptyContainer.Clear ();
                        foreach (Container c in toplevels)
                            c.SizeChanged ();
                        Refresh ();
                    }
                    continue;
                }

                if (ch == Curses.KeyMouse){
                    Curses.MouseEvent ev;

                    Curses.console_sharp_getmouse (out ev);
                    container.ProcessMouse (ev);
                    continue;
                }

                if (ch == 27){
                    Curses.timeout (100);
                    int k = Curses.getch ();
                    if (k != Curses.ERR && k != 27)
                        ch = Curses.KeyAlt | k;
                    Curses.timeout (Timeout);
                }

                if (container.ProcessHotKey (ch))
                    continue;

                if (container.ProcessKey (ch))
                    continue;

                if (container.ProcessColdKey (ch))
                    continue;

                // Control-c, quit the current operation.
                if (ch == 3)
                    break;

                // Control-z, suspend execution, then repaint.
                if (ch == 26){
                    Curses.console_sharp_sendsigtstp ();
                    Window.Standard.redrawwin ();
                    Curses.refresh ();
                }

                //
                // Focus handling
                //
                if (ch == 9 || ch == Curses.KeyDown || ch == Curses.KeyRight){
                    if (!container.FocusNext ())
                        container.FocusNext ();
                    continue;
                } else if (ch == Curses.KeyUp || ch == Curses.KeyLeft){
                    if (!container.FocusPrev ())
                        container.FocusPrev ();
                    continue;
                }

            }

            toplevels.Remove (container);
            if (toplevels.Count == 0)
                Shutdown ();
            else
                Refresh ();
        }