Exemple #1
0
        // Protected methods

        protected void OnButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            int x, y;

            Gdk.ModifierType state;
            args.Event.Window.GetPointer(out x, out y, out state);

            if (activeAction == null && IsInBounds(x, y))
            {
                foreach (TileGridAction act in actionList)
                {
                    if (act.MatchesState(state))
                    {
                        HandleTileGridAction(act, GetGridIndex(x, y));

                        if (act.mod.HasFlag(MouseModifier.Drag))
                        {
                            activeAction = act;
                        }
                    }
                }

                if (Selectable)
                {
                    GrabFocus();
                }
            }
        }
Exemple #2
0
 void HandleTileGridAction(TileGridAction act, int index)
 {
     if (act.action == GridAction.Select)
     {
         SelectedIndex = index;
     }
     else if (act.action == GridAction.Callback)
     {
         act.callback(this, index);
     }
 }
Exemple #3
0
        protected void OnButtonReleaseEvent(object o, ButtonReleaseEventArgs args)
        {
            int x, y;

            Gdk.ModifierType state;
            args.Event.Window.GetPointer(out x, out y, out state);

            if (activeAction != null && !activeAction.ButtonMatchesState(state))
            {
                if (activeAction.mod.HasFlag(MouseModifier.Drag))
                {
                    // Probably will add a "button release" callback here later
                    activeAction = null;
                }
            }
        }
Exemple #4
0
        public void AddMouseAction(MouseButton button, MouseModifier mod, GridAction action, TileGridEventHandler callback = null)
        {
            TileGridAction act;

            if (action == GridAction.Callback)
            {
                if (callback == null)
                {
                    throw new Exception("Need to specify a callback.");
                }
                act = new TileGridAction(button, mod, action, callback);
            }
            else
            {
                if (callback != null)
                {
                    throw new Exception("This action doesn't take a callback.");
                }
                act = new TileGridAction(button, mod, action);
            }

            actionList.Add(act);
        }