我在做一个游戏使用Windows窗体一个关卡编辑器。的形式有几个下拉菜单,文本框等,用户可以在其中输入信息
I'm making a level editor for a game using windows forms. The form has several drop down menus, text boxes, etc, where the user can type information.
我想为游戏世界本身的工作就像 CTRL + V
或 Ctrl + A
可用命令,而不是文本操作。游戏的世界是psented再$ P $一个图片框
包含在面板
。
I want to make commands like CTRL + V
or CTRL + A
available for working within the game world itself, not text manipulation. The game world is represented by a PictureBox
contained in a Panel
.
此事件处理函数不是永远射击:
This event handler isn't ever firing:
private System.Windows.Forms.Panel canvas;
// ...
this.canvas = new System.Windows.Forms.Panel();
// ...
this.canvas.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.canvas_PreviewKeyDown);
什么是$ P $这样做的pferred方式?可以在面板
即使接收键盘输入?在游戏世界中的配售对象的时候,我想允许用户与文本输入操作时使用的复制/粘贴/全选命令,但不是。
What is the preferred way of doing this? Can a panel
even receive keyboard input? I would like to allow the user to use copy/paste/select-all commands when working with the text input, but not when placing objects in the game world.
您可能会想这样做的关键捕获在表单级别。这是强烈建议从谁帮写底层的.NET code的人阅读:
You'll probably want to do the key capture at the form level. This is highly recommended reading from the person who helped write the underlying .NET code:
http://blogs.msdn.com/jfoscoding/存档/ 2005/01/24 / 359334.aspx