Пример #1
0
        protected CocoStudio.Model.PointF GetVectorByKey(Gdk.Key key)
        {
            CocoStudio.Model.PointF pointF = new CocoStudio.Model.PointF(0f, 0f);
            switch (key)
            {
            case Gdk.Key.Left:
                pointF.X = -1f;
                break;

            case Gdk.Key.Up:
                pointF.Y = 1f;
                break;

            case Gdk.Key.Right:
                pointF.X = 1f;
                break;

            case Gdk.Key.Down:
                pointF.Y = -1f;
                break;
            }
            CocoStudio.Model.PointF result;
            if (pointF.X == 0f && pointF.Y == 0f)
            {
                result = null;
            }
            else
            {
                result = pointF;
            }
            return(result);
        }
Пример #2
0
 public static void SetButtonDown(Gdk.Key key)
 {
     if (buttons.ContainsKey(key))
     {
         buttons [key].Press();
     }
 }
 internal CellKeyPressEventArgs(int column, int row, Entry entry, EventKey eventKey, Gdk.Key gdkKey)
     : base(column, row)
 {
     this.entry    = entry;
     this.eventKey = eventKey;
     this.gdkKey   = gdkKey;
 }
Пример #4
0
        public static void MapRawKeys(EventKey evt, out Key key, out ModifierType mod)
        {
            mod = GetAllowedModifier(evt.State);
            key = evt.Key;
            if (PlatformHelper.Platform != PlatformTypes.MacOSX)
            {
                return;
            }

            uint         keyval;
            int          effectiveGroup, level;
            ModifierType consumedModifiers;

            Keymap.Default.TranslateKeyboardState(evt.HardwareKeycode, evt.State, evt.Group, out keyval, out effectiveGroup,
                                                  out level, out consumedModifiers);

            key = (Key)keyval;
            mod = evt.State & ~consumedModifiers;

            AccelKey accelKey = MapRawKeys(new AccelKey(key, mod, AccelFlags.Visible));

            key = accelKey.Key;
            mod = accelKey.AccelMods;

            // When opt modifier is active, we need to decompose this to make the command appear correct for Mac.
            // In addition, we can only inspect whether the opt/alt key is pressed by examining
            // the key's "group", because the Mac GTK+ treats opt as a group modifier and does
            // not expose it as an actual GDK modifier.
            if (evt.Group == (byte)1)
            {
                mod |= AltModifier;
                key  = GetGroupZeroKey(key, evt);
            }
        }
Пример #5
0
 public static void SetButtonUp(Gdk.Key key)
 {
     if (buttons.ContainsKey(key))
     {
         buttons [key].Release();
     }
 }
Пример #6
0
    public void keyPressed(Gdk.Key keyCode)
    {
        //WriteLine("Hello button!");
        if (Grid.TilesAnimationsDone == 16)
        {
            switch (keyCode)
            {
            case Gdk.Key.Up:
                Console.WriteLine("UP");
                Game.BOARD.MoveUp();
                break;

            case Gdk.Key.Down:
                Console.WriteLine("DOWN");
                Game.BOARD.MoveDown();
                break;

            case Gdk.Key.Left:
                Console.WriteLine("LEFT");
                Game.BOARD.MoveLeft();
                break;

            case Gdk.Key.Right:
                Console.WriteLine("RIGHT");
                Game.BOARD.MoveRight();
                break;

            default:
                break;
            }
        }

        Game.BOARD.IsGameOver();
        Game.WINDOW.StartAnimation();
    }
Пример #7
0
        protected virtual void ItemColumnEditNext(int row, Key keyCode)
        {
            if (!codeQtty.IsZero())
            {
                QtyColumnEvaluate(row, codeQtty);
            }

            if (barcodeUsed)
            {
                if (codeQtty.IsZero())
                {
                    QtyColumnEvaluate(row, 1);
                }

                if (selectedDetails.Count <= row + 1)
                {
                    selectedDetails.AddNew();
                }

                EditGridCell(row + 1, colItem.Index);
            }
            else if (colQtty != null && colQtty.ListCell.IsEditable)
            {
                EditGridCell(row, colQtty.Index);
            }
            else
            {
                QtyColumnEditNext(row, keyCode);
            }
        }
Пример #8
0
        static Gdk.Key GetGroupZeroKey(Gdk.Key mappedKey, Gdk.EventKey evt)
        {
            Gdk.Key ret;
            if (groupZeroMappings.TryGetValue(mappedKey, out ret))
            {
                return(ret);
            }

            //LookupKey isn't implemented on Mac, so we have to use this workaround
            uint[]           keyvals;
            Gdk.KeymapKey [] keys;
            keymap.GetEntriesForKeycode(evt.HardwareKeycode, out keys, out keyvals);

            //find the key that has the same level (so we preserve shift) but with group 0
            for (uint i = 0; i < keyvals.Length; i++)
            {
                if (keyvals[i] == (uint)mappedKey)
                {
                    for (uint j = 0; j < keys.Length; j++)
                    {
                        if (keys[j].Group == 0 && keys[j].Level == keys[i].Level)
                        {
                            return(groupZeroMappings[mappedKey] = ret = (Gdk.Key)keyvals[j]);
                        }
                    }
                }
            }

            //failed, but avoid looking it up again
            return(groupZeroMappings[mappedKey] = mappedKey);
        }
 public KeyNode(KeyCommand command, Gdk.Key key)
 {
     this.Key        = key;
     commandString   = KeyCommandToString(command);
     this.keyCommand = command;
     Pressed         = false;
 }
Пример #10
0
        bool ITextEditorExtension.KeyPress(Gdk.Key key, char ch, Gdk.ModifierType modifier)
        {
            Gdk.EventKey evnt = evntCopy;
            HideLanguageItemWindow();

            bool        res    = false;
            IEditAction action = editactions.GetAction(evnt.Key, evnt.State);

            if (action != null)
            {
                action.PreExecute(this);
                if (action.PassToBase)
                {
                    base.OnKeyPressEvent(evnt);
                }

                action.Execute(this);

                if (action.PassToBase)
                {
                    base.OnKeyPressEvent(evnt);
                }
                action.PostExecute(this);

                res = true;
            }
            else
            {
                res = base.OnKeyPressEvent(evnt);
            }
            return(res);
        }
Пример #11
0
        public static void PostProcessKeyEvent(ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier)
        {
            // Called after the key has been processed by the editor

            if (methods.Count == 0)
            {
                return;
            }

            for (int n = 0; n < methods.Count; n++)
            {
                // If the cursor is outside of any of the methods parameter list, discard the
                // information window for that method.

                MethodData md  = methods [n];
                int        pos = md.MethodProvider.GetCurrentParameterIndex(widget, md.CompletionContext);
                if (pos == -1)
                {
                    methods.RemoveAt(n);
                    n--;
                }
            }
            // If the user enters more parameters than the current overload has,
            // look for another overload with more parameters.
            UpdateOverload(widget);

            // Refresh.
            UpdateWindow(widget);
        }
Пример #12
0
 public static bool GetButtonUp(Gdk.Key key)
 {
     if (buttons.ContainsKey(key))
     {
         return(buttons [key].ButtonUp);
     }
     return(false);
 }
Пример #13
0
            public KeyBind(KeyBind keyBind)
            {
                gtkKey = keyBind.gtkKey;

                sdlKey = keyBind.sdlKey;

                gameBoyKey = keyBind.gameBoyKey;
            }
Пример #14
0
            public KeyBind(Gdk.Key gtk, SDL2.SDL.SDL_Keycode sdl, GameBoyKeys gbk)
            {
                gtkKey = gtk;

                sdlKey = sdl;

                gameBoyKey = gbk;
            }
Пример #15
0
 private void Entry_KeyReleaseEvent(object o, KeyReleaseEventArgs args)
 {
     this.isKeyPress = true;
     Gdk.Key key = args.Event.Key;
     if ((key == Gdk.Key.Return || key == Gdk.Key.KP_Enter || key == Gdk.Key.ISO_Enter) && this.combox.Entry.IsFocus)
     {
         this.FontValue();
     }
 }
Пример #16
0
        public static void TypeKey(Widget target, Gdk.Key key, ModifierType modifier, bool wait = true)
        {
            SendKeyEvent(target, (uint)key, modifier, EventType.KeyPress);
            SendKeyEvent(target, (uint)key, modifier, EventType.KeyRelease);

            if (wait)
            {
                WaitForGtkEvents();
            }
        }
 public GcKeyEventArgs( Gtk.Widget sender, Gdk.EventKey args, bool key_pressed_suppressed )
 {
     control  = ( (args.State & ModifierType.ControlMask) == ModifierType.ControlMask );
     shift    = ( (args.State & ModifierType.ShiftMask  ) == ModifierType.ShiftMask   );
     alt      = ( (args.State & ModifierType.Mod1Mask   ) == ModifierType.Mod1Mask    );
     widget   = sender;
     keyCode  = args.Key;
     keyValue = (int)args.KeyValue;
     suppressKeyPress = key_pressed_suppressed;
 }
Пример #18
0
 bool IsSupportedModifier(Gdk.Key key)
 {
     return(key == Gdk.Key.Shift_L ||
            key == Gdk.Key.Shift_R ||
            key == Gdk.Key.Alt_L ||
            key == Gdk.Key.Alt_R ||
            key == Gdk.Key.Control_L ||
            key == Gdk.Key.Control_R ||
            key == (Gdk.Key)ModifierType.None);
 }
 public GcKeyEventArgs(Gtk.Widget sender, Gdk.EventKey args, bool key_pressed_suppressed)
 {
     control          = ((args.State & ModifierType.ControlMask) == ModifierType.ControlMask);
     shift            = ((args.State & ModifierType.ShiftMask) == ModifierType.ShiftMask);
     alt              = ((args.State & ModifierType.Mod1Mask) == ModifierType.Mod1Mask);
     widget           = sender;
     keyCode          = args.Key;
     keyValue         = (int)args.KeyValue;
     suppressKeyPress = key_pressed_suppressed;
 }
        /// <summary>
        /// Handles a key press and performs the appropriate action.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="unicodeKey">The Unicode key.</param>
        /// <param name="modifier">The modifier.</param>
        public bool HandleKeyPress(
            Key key,
            ModifierType modifier,
            uint unicodeKey)
        {
            // Normalize the key code and remove excessive modifiers.
            ModifierType filteredModifiers = modifier
                                             & (ModifierType.ShiftMask | ModifierType.Mod1Mask | ModifierType.ControlMask
                                                | ModifierType.MetaMask | ModifierType.SuperMask);
            int keyCode = GdkUtility.GetNormalizedKeyCode(key, filteredModifiers);

            // Check to see if we have an action for this.
            ModifierType isNormalOrShifted = filteredModifiers & ~ModifierType.ShiftMask;
            bool         isCharacter       = unicodeKey != 0 && isNormalOrShifted == ModifierType.None;
            bool         isAction          = keyBindings.ContainsKey(keyCode);

            if (isAction || isCharacter)
            {
                // Keep track of the original selection.
                TextRange previousSelection = displayContext.Caret.Selection;

                // Mark that we are starting a new action and fire events so
                // other listeners and handle it.
                InAction = true;

                // Perform the appropriate action.
                try
                {
                    if (isAction)
                    {
                        keyBindings[keyCode].Perform(this);
                    }
                    else
                    {
                        TextActions.InsertText(this, (char)unicodeKey);
                    }
                }
                finally
                {
                    InAction = false;
                }

                // Check to see if the selection changed.
                if (previousSelection != displayContext.Caret.Selection)
                {
                    displayContext.Renderer.UpdateSelection(displayContext, previousSelection);
                }

                // We did something, so return processed.
                return(true);
            }

            // No idea what to do, so don't do anything.
            return(false);
        }
Пример #21
0
        internal bool IsPressed(Key key)
        {
            if (key == Key.Unbound || key == Key.Unknown)
            {
                return(false);
            }

            GtkKey nativeKey = GTK3MappingHelper.ToGtkKey(key);

            return(_pressedKeys.Contains(nativeKey));
        }
Пример #22
0
        public static int GetKeyCode(Gdk.Key key, Gdk.ModifierType modifier)
        {
            uint m = (uint)(((modifier & Gdk.ModifierType.ControlMask) != 0)? 1 : 0);

            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.ShiftMask) != 0)? 1 : 0);
            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.MetaMask) != 0)? 1 : 0);
            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.Mod1Mask) != 0)? 1 : 0);
            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.SuperMask) != 0)? 1 : 0);

            return(GetKeyCode(key) | (int)(m << 16));
        }
Пример #23
0
        bool IsDotCompletion(Gdk.Key key)
        {
            if (key != Gdk.Key.period || completionWindow.Visible)
            {
                return(false);
            }

            // TODO: Handle numbers like mono's REPL?
            // https://github.com/mono/mono/blob/71307187cb1e9d8202d30fcaa1f5c4e4a66bc551/mcs/tools/csharp/getline.cs#L1060
            return(true);
        }
Пример #24
0
        //	string status;

        public void InternalHandleKeypress(TextEditor editor, TextEditorData data, Gdk.Key key,
                                           uint unicodeChar, Gdk.ModifierType modifier)
        {
            this.editor         = editor;
            this.textEditorData = data;

            HandleKeypress(key, unicodeChar, modifier);

            //make sure that nothing funny goes on when the mode should have finished
            this.textEditorData = null;
            this.editor         = null;
        }
Пример #25
0
        public void SetKey(GameBoyKeys gbk, Gdk.Key gtk)
        {
            for (int i = 0; i < KeyBinds.Length; i++)
            {
                if(KeyBinds[i].gameBoyKey != gbk)
                    continue;

                KeyBinds[i].gtkKey = gtk;

                KeyBinds[i].sdlKey = MapGtkToSDL(gtk) ?? SDL2.SDL.SDL_Keycode.SDLK_F24;
            }
        }
Пример #26
0
        public static Button RegisterButton(Gdk.Key key)
        {
            if (buttons.ContainsKey(key))
            {
                return(null);
            }
            Button bt = new Button();

            buttons.Add(key, bt);
            buttonsByString.Add(key.ToString(), bt);
            return(bt);
        }
Пример #27
0
 public void HistoryKeyHandler(Gdk.Key key)
 {
     if (key == Gdk.Key.Up)
     {
         history.Previous();
         input.Text = history.Get();
     }
     else if (key == Gdk.Key.Down)
     {
         history.Next();
         input.Text = history.Get();
     }
 }
Пример #28
0
        protected override void HandleKeypress(Gdk.Key key, uint unicodeKey, Gdk.ModifierType modifier)
        {
            int keyCode = GetKeyCode(key, modifier);

            if (keyBindings.ContainsKey(keyCode))
            {
                RunAction(keyBindings [keyCode]);
            }
            else if (unicodeKey != 0 && modifier == Gdk.ModifierType.None)
            {
                InsertCharacter(unicodeKey);
            }
        }
Пример #29
0
        public void AddBinding(Gdk.Key key, Action <TextEditorData> action, bool force = false)
        {
            var code = GetKeyCode(key);

            if (force)
            {
                if (keyBindings.ContainsKey(code))
                {
                    keyBindings [code] = action;
                    return;
                }
            }
            keyBindings.Add(code, action);
        }
Пример #30
0
        // Called when a key is pressed in the editor.
        // Returns false if the key press has to continue normal processing.
        public static bool ProcessKeyEvent(ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier)
        {
            if (methods.Count == 0)
            {
                return(false);
            }

            MethodData cmd = methods [methods.Count - 1];

            if (key == Gdk.Key.Down)
            {
                if (cmd.MethodProvider.OverloadCount <= 1)
                {
                    return(false);
                }
                if (cmd.CurrentOverload < cmd.MethodProvider.OverloadCount - 1)
                {
                    cmd.CurrentOverload++;
                }
                else
                {
                    cmd.CurrentOverload = 0;
                }
                UpdateWindow(widget);
                return(true);
            }
            else if (key == Gdk.Key.Up)
            {
                if (cmd.MethodProvider.OverloadCount <= 1)
                {
                    return(false);
                }
                if (cmd.CurrentOverload > 0)
                {
                    cmd.CurrentOverload--;
                }
                else
                {
                    cmd.CurrentOverload = cmd.MethodProvider.OverloadCount - 1;
                }
                UpdateWindow(widget);
                return(true);
            }
            else if (key == Gdk.Key.Escape)
            {
                HideWindow(widget);
                return(true);
            }
            return(false);
        }
Пример #31
0
 public override void SelectValidShortcut(KeyboardShortcut[] accels, out Gdk.Key key, out ModifierType mod)
 {
     foreach (var accel in accels)
     {
         int keyCode = GetKeyCode(accel.Key, accel.Modifier);
         if (keyBindings.ContainsKey(keyCode))
         {
             key = accel.Key;
             mod = accel.Modifier;
             return;
         }
     }
     key = accels [0].Key;
     mod = accels [0].Modifier;
 }