コード例 #1
0
 void KeyDown(object sender, KeyboardKeyEventArgs e)
 {
     if (e.Key == Key.Tab)
     {
         HandleTab();
     }
     else if (e.Key == Key.Enter)
     {
         LauncherWidget widget = selectedWidget;
         if (widget != null && widget.OnClick != null)
         {
             widget.OnClick(0, 0);
         }
     }
 }
コード例 #2
0
        protected void MouseButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.Button != MouseButton.Left)
            {
                return;
            }

            if (lastClicked != null && lastClicked != selectedWidget)
            {
                WidgetUnclicked(lastClicked);
            }
            if (selectedWidget != null && selectedWidget.OnClick != null)
            {
                selectedWidget.OnClick(e.X, e.Y);
            }
            lastClicked = selectedWidget;
        }
コード例 #3
0
        protected virtual void KeyDown(object sender, KeyboardKeyEventArgs e)
        {
            if (e.Key == Key.Enter && enterIndex >= 0)
            {
                LauncherWidget widget = (selectedWidget != null && mouseMoved) ?
                                        selectedWidget : widgets[enterIndex];
                if (widget.OnClick != null)
                {
                    widget.OnClick(0, 0);
                }
            }
            else if (e.Key == Key.Tab)
            {
                HandleTab();
            }
            if (lastInput == null)
            {
                if (e.Key == Key.Escape)
                {
                    game.SetScreen(new MainScreen(game));
                }
                return;
            }

            if (e.Key == Key.BackSpace && lastInput.BackspaceChar())
            {
                RedrawLastInput();
                OnRemovedChar();
            }
            else if (e.Key == Key.Delete && lastInput.DeleteChar())
            {
                RedrawLastInput();
                OnRemovedChar();
            }
            else if (e.Key == Key.C && ControlDown)
            {
                lastInput.CopyToClipboard();
            }
            else if (e.Key == Key.V && ControlDown)
            {
                if (lastInput.CopyFromClipboard())
                {
                    RedrawLastInput();
                }
            }
            else if (e.Key == Key.Escape)
            {
                if (lastInput.ClearText())
                {
                    RedrawLastInput();
                }
            }
            else if (e.Key == Key.Left)
            {
                lastInput.AdvanceCursorPos(-1);
                RedrawLastInput();
            }
            else if (e.Key == Key.Right)
            {
                lastInput.AdvanceCursorPos(+1);
                RedrawLastInput();
            }
        }