示例#1
0
        public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct)
        {
            switch (message)
            {
            // middle click : go to definition
            case WinApi.Messages.WM_MBUTTONDOWN:
                if (Npp.CurrentFileInfo.IsProgress)
                {
                    if (KeyboardMonitor.GetModifiers.IsCtrl)
                    {
                        Npp.GoBackFromDefinition();
                    }
                    else
                    {
                        ProMisc.GoToDefinition(true);
                    }
                }
                return(true);

            //break;
            // (CTRL + ) Right click : show main menu
            case WinApi.Messages.WM_RBUTTONUP:
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    // we need the cursor to be in scintilla but not on the application or the autocompletion!
                    if ((!Appli.IsVisible || !Appli.IsMouseIn()) &&
                        (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) &&
                        (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn()))
                    {
                        AppliMenu.ShowMainMenu(true);
                        return(true);
                    }
                }
                break;
            }

            return(false);
        }
示例#2
0
        public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct)
        {
            switch (message)
            {
            // middle click : go to definition
            case WinApi.Messages.WM_MBUTTONDOWN:
                if (Npp.CurrentFileInfo.IsProgress)
                {
                    if (KeyboardMonitor.GetModifiers.IsCtrl)
                    {
                        Npp.GoBackFromDefinition();
                    }
                    else
                    {
                        ProMisc.GoToDefinition(true);
                    }
                }
                return(true);

            //break;
            // (CTRL + ) Right click : show main menu
            case WinApi.Messages.WM_RBUTTONUP:
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    // we need the cursor to be in scintilla but not on the application or the autocompletion!
                    if ((!Appli.IsVisible || !Appli.IsMouseIn()) &&
                        (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) &&
                        (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn()))
                    {
                        AppliMenu.ShowMainMenu(true);
                        return(true);
                    }
                }
                break;
            }

            // HACK: The following is to handle the MOVE/RESIZE event of npp's window.
            // It would be cleaner to use a WndProc bypass but it costs too much... this is a cheaper solution
            switch (message)
            {
            case WinApi.Messages.WM_NCLBUTTONDOWN:
                if (!WinApi.GetWindowRect(Npp.CurrentSci.Handle).Contains(Cursor.Position))
                {
                    MouseMonitor.Instance.Add(WinApi.Messages.WM_MOUSEMOVE);
                }
                break;

            case WinApi.Messages.WM_LBUTTONUP:
            case WinApi.Messages.WM_NCLBUTTONUP:
                if (MouseMonitor.Instance.Remove(WinApi.Messages.WM_MOUSEMOVE))
                {
                    if (OnNppWindowsMove != null)
                    {
                        OnNppWindowsMove();
                    }
                }
                break;

            case WinApi.Messages.WM_MOUSEMOVE:
                if (OnNppWindowsMove != null)
                {
                    OnNppWindowsMove();
                }
                break;
            }

            return(false);
        }