I am working on an application that has multiple dockable panels like Visual Studio. At some point the accelerator keys for the menu stopped working. They sometimes work depending on what panel is currently active. When they are not working pressing the alt key sets the focus to the menu bar and shows the underscores under the appropriate characters, but pressing any of the characters does not show the menu.
I've been banging my head against this for a little bit and am wondering if there is an easier way to find out what is happening to those key presses.
The first place to look is in any key press handlers within your code. I would set a breakpoint in all of those and see if those event handlers are stopping the key press from being bubbled up.
I found that there was a control that had overridden Control.ProcessMnemonic(). There was a logic error that was returning true when it should have been returning false.
Not exactly an easy error to find without spending a lot if time.
Related
I'm facing a tough one right now, at least it's tough for me!
I'm using this code to capture key press events and it works just fine even when the window is out of focus.
In addition though, I'd like to be able to consume the key event before it is used by any other application that does have the focus right now.
Search after search has brought no result for me, does anyone know how this might be accomplished?
Im sure there is a simpliest way to to this (the code you use is old), but I've found this post. (Look at the code at the end)
Anyway, you can always use the 'KeyEventArgs.Handled = true;' property in the 'KeyDown' and 'KeyUp' event of your focused control to limite the key's propagation.
Here is the source code of a program that captures every key on windows, records it, and then passes it on to the next program.
You could take that code as a starting point and conditionally execute the call to CallNextHookEx to consume the keys.
I use Ctrl+M, Ctrl+M to collapse/expand modules in the text editor.
But since the last few days, it shows weird behaviour. I do not know how to grammatically describe the problem, hence I have not been able to google out a solution.
Pics are attached. How can I make it normal again?
Edit: How can I reset the vs-editor to default values (If there is such a thing)?
Thanks
Go to Options>Environment>Keyboard
Press the reset button step1
Secondly from the keyboard mapping scheme choose Visual C# 2005 step2
Alternatevly if this does not work press CTRL+M,CTRL+O and then press CTRL+M,CTRL+L and then try using CTRL+M,CTRL+M
Hope this helps
I often found useful informations here, now it was time to create an account on my own and say thanks to this community for it helped me so often!
I am currently coding a game in Monogame 3.2 in Mac OSX 10.9.5 using Xamarin 5.5.4 and encountering a strange problem I've never seen before: when I press one of the arrow keys it seems as if the shift keys, both left and right, are always considered to be NOT PRESSED, even if I press them.
I checked this with these lines of code inside my game loop:
foreach (Keys key in Keyboard.GetState().GetPressedKeys()) {
Console.WriteLine (key.ToString ());
}
The output is always the same. When I press one of the shift keys only or first (and hold), I get
LeftShift
RightShift
Plus eventually the arrow keys (if shift was hold first). But when I press one of the arrow keys first and then press the shift key while one of the arrow keys is down, those two do not appear.
That's obviously a problem because my game character now cannot run when shift is pressed (at least when the arrow keys were pressed first and hold). I double checked if other keys like Z are also blocked, but it seems as if the arrow keys only block shift (but I haven't checked every key so far).
Does anyone know why this happens? I checked whether or not sticky keys is activated in Mac OSX, but it's not. Sadly, I couldn't find anything on the internet so far.
Any help is appreciated! Thanks a lot in advance!
I think MonoGame is doing a few special things to get certain keys to work on windows, might be some of these same fixes need to be done on other platforms.
Try locating the code in MonoGame that translates from OS key events to XNA key events. It is most likely where the problem is.
Also try running the most recent develop branch just to be sure it isn't a bug that was fixed in the mean time.
In c# applications using WPF, including a very simple one with 1 button,
I have several shortcut keys. They all behave in the following manner
Alt+Shortcut key pressed at the same time works, Shortcut key on its own works (not what I was expecting without showing the underscore unless it is shown already). Alt followed by short cut key goes beep and does not work, presumably reporting some error.
What is going on here? How can I get consistent behaviour. In WinForms it used to be just Alt+Shortkey that worked. That is what I would like unless the standard behaviour has changed.
thanks
But that is how it works
Alt + key is how you execute the short cut
Alt alone just turns the shortcut indicator on and off
I'm programming an application consisting of three usercontrols in an main window.
In one of the usercontrols, there's a slider that needs to be controllable by keyboard input. The left arrow should decrease value, right button increase and so on. I have this work, but only when the slider has focus. If some other control has focus, I cant make it work at all.
Is it possible to define "global" hotkeys? IE keys that trigger the same event or function, no matter where the focus is? Hope I've made myself clear enough...
I have never tried this but If you have a command registered at the main window level with keys associated to it that might work. Keep in mind I have never done this but it is some thing you can try. If you are new to commands here is a blog post about it.
I have never rolled this my self but when using the built in past command I actually had to put code in to prevent it from happening in some cases.
I know this probably isn't much help but I hope it is enough to get you started.