|
-
July 10th, 2012, 08:27 PM
#21
Re: Some questions regarding my project
 Originally Posted by Tusike
-If I want to detect keyboard shortcuts (key presses), like "Delete", "F1", "CTRL-S", "ESC", etc... which event should handle those, so it gets detected (without a sound..)? For example, I have a tabpage that displays all the words in a list; I want to be able to edit/delete/add new words using the keyboard, and not right clicking.
This first thing you should do here is forget about the KeyPess handler, since that only catches character input keys, and only two of those you listed at least remotely belong to that category: Ctrl+S and Esc (which technically, at least from the ASCII perspective, is Ctrl+[). The event in charge here is KeyDown which catches almost everything (thereby increasing the effort you need to filter out the unneeded stuff, though). As you seem to intend to use these keys as a replacement for the menu your program doesn't have, the right instance to hanndle the KeyDown probably is the form. The KeyDown event is subject to the same caveats issued earlier on, but this time it really seems to be the means of choice. And as at least the Del listed here is a keystroke that is also consumed by text boxes, chances are you'll need to set the form's KeyPreview property to true.
There are two keys on your list that are still critical, though. Just recently I tried to intercept and exclusively (but conditionally) handle Esc myself in a modal dialog (that did have a CancelButton) of one of my projects, with the final result (though it took some time to get there) that I abandoned that idea entirely and resorted to an alternative approach not involving that key at all. F1, as the standard Help key, may be subject to some special treatment by the framework as well. I never tried to make personal use of it, but at least you should be on your guard. Like me you may find out that using a different key or a more fundamentally different solution is the better idea.
-To use my ContextMenuStrips, I first have to left click on an item to select it, then right click to get the menustrip with that item selected. Can I do something to have right-click select that item and bring up the contextmenu, and so avoiding the left-click?
I didn't ever try that with a list box, but in one of my recent apps I do that with both a list view and a tree view. The list view is completely uncritical in this respect since it actually does select an item upon right click. The tree view does not, however, and for that I have this MouseClick handler:
Code:
System::Void Form1::treeView1_MouseClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
if (e->Button == Windows::Forms::MouseButtons::Right)
m_tnRightClickedNode = treeView1->GetNodeAt(e->Location);
}
In the context menu's Opening handler I then check whether m_tnRightClickedNode is nullptr and if it is (which means the right click didn't hit any node) I apply the context menu to the currently selected node, otherwise to m_tnRightClickedNode. That selected node may be quite some space away from the mouse click in this case, so you may alternatively want to simply refuse to open the context menu by setting e->Cancel to true in the Opening handler.
-Is it possible to change the input keyboard? I currently have english, german, and hungarian keyboards added, and it would be great if the program could automatically switch between these as needed, this would save a lot of time in adding new words + when the words are asked in a random language.
It probably is, but I don't know how. Chances are that this only can be done the native way, so you may need interop. But I, as a German, know how tideous it is to enter German umlauts on, say, a US keyboard, even for one who sits in front of a German keyboard many hours a day and perhaps could be expected to know by heart where the respective keys are. You don't expect your users to have a decent collection of international physical keyboards at hand, do you? Aside from the fact that switching physical keyboards during system runtime isn't completely unproblemaic either. Have you considered offering virtual keyboards for languages that are incompatible to the host system's language?
Some additional general notes: Your program already does defy practically any common Windows GUI habit it finds anyway, so asking you to better accomodate to them would come close to demanding a complete rewrite of your program. But mind this: When I started your program the first time, I had no idea how to start the quiz. It took me some time to figure it out. Just a few dozen seconds, but keep in mind that I'm an experienced developer who can ask oneself questions like "What are possible interactions with Windows controls [that in addition I'd need to identify as what they are] that the program's author might expect me to use?". Many "ordinary users" probably would have given up after at most three to five minutes or so, closed your program and then never opened it again.
Last edited by Eri523; July 11th, 2012 at 06:34 AM.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|