Ejemplo n.º 1
0
 private void OnKeyPress(object sender, KeyPressEventArgs args)
 {
     if ((args.Event.State & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.space)
     {
         /*
          * Point p = textEditor.TextArea.LocationToPoint(textEditor.Caret.Location);
          * p.Y += (int)textEditor.LineHeight;
          * // Need to convert to screen coordinates....
          * int x, y, frameX, frameY;
          * MasterView.MainWindow.GetOrigin(out frameX, out frameY);
          * textEditor.TextArea.TranslateCoordinates(_mainWidget.Toplevel, p.X, p.Y, out x, out y);
          */
         if (IntellisenseItemsNeeded != null)
         {
             int x, y;
             textentry1.GdkWindow.GetOrigin(out x, out y);
             Tuple <int, int>     coordinates = new Tuple <int, int>(x, y + textentry1.SizeRequest().Height);
             NeedContextItemsArgs e           = new NeedContextItemsArgs()
             {
                 Coordinates = coordinates,
                 Code        = textentry1.Text,
                 Offset      = Offset
             };
             lastText = textentry1.Text;
             IntellisenseItemsNeeded.Invoke(this, e);
         }
     }
     else if ((args.Event.Key & Gdk.Key.Return) == Gdk.Key.Return)
     {
         OnSelectionChanged(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 2
0
        private void OnKeyPress(object sender, KeyPressEventArgs args)
        {
            bool controlSpace      = (args.Event.State & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.space;
            bool controlShiftSpace = controlSpace && (args.Event.State & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask;
            bool isPeriod          = args.Event.Key == Gdk.Key.period;

            if (isPeriod || controlSpace || controlShiftSpace)
            {
                if (IntellisenseItemsNeeded != null)
                {
                    int x, y;
                    textentry1.GdkWindow.GetOrigin(out x, out y);
                    System.Drawing.Point coordinates = new System.Drawing.Point(x, y + textentry1.SizeRequest().Height);
                    NeedContextItemsArgs e           = new NeedContextItemsArgs()
                    {
                        Coordinates       = coordinates,
                        Code              = textentry1.Text,
                        ControlSpace      = controlSpace,
                        ControlShiftSpace = controlShiftSpace,
                        Offset            = Offset,
                        ColNo             = this.textentry1.CursorPosition
                    };
                    lastText = textentry1.Text;
                    IntellisenseItemsNeeded.Invoke(this, e);
                }
            }
            else if ((args.Event.Key & Gdk.Key.Return) == Gdk.Key.Return)
            {
                OnSelectionChanged(this, EventArgs.Empty);
            }
        }