I have a function that displays an object on screen when a key is pressed. I should be able to left click this object while the key is pressed and the program makes a change to the object on the click - this is not happening. I put a breakpoint into the left mouse click handler. Pressed the key and clicked the object. Switching to VS2010 I get a message that I cannot Edit and Continue at that point. If I lift off the key press then I can debug. However I am concerned that there may be something else reacting to the key press causing the change in the object to fail.
A quick update - if I disable the actions from the Key Up event then everything works.
My question is therefore if there is any way to debug in VS2010 with a key pressed.
Thanks
Use Tracepoints. This will allow you to add trace messages and output the value of variables without needing to stop in the debugger. Key presses and mouse clicks will therefore not interfere with the debugger.
Related
My team and I made a game version of Snake, and everything works well except after I push the right arrow key, then the key events stop firing. I have tried setting Keyboard.Focus and other focus methods, but it doesn't work.
Our project is on github at: csis2530, look for bbarke.
I don't know why the key down event stops working after the right arrow key has been pressed.
I hope someone could help us.
I fixed the gui by ensuring that the GameWindow has the focus and only the GameWindow has the focus. This is what you do:
Click on the New Game button, go to its property and search for "Focusable". Then UNcheck the Focusable checkbox. Do this for the combobox (the one that has the levels), the high score button, and the apples eaten label, and everything else EXCEPT for the Game Window. Make sure that the GameWindow has the focus and make sure that its Focusable is checked.
I noticed that when I push on the arrow keys, the combo box would change. This is due to the focus from the GameWindow being taken away by the combo box.
So make sure that only the GameWindow has the Focusable property checked.
I've seen plenty of information about this topic, but not the answer to this question exactly. I have the opposite problem of most. I want to prevent the Enter button from clicking a button when the button has focus. And to do this, I don't want to simply disable the button from accepting an Enter button press, but rather I want to conditionally capture the Enter button press in a callback method. Right now, I have bound the following event to all widgets in my python program:
parent.Bind(wx.EVT_CHAR, self.CharInputCallback)
The EVT_CHAR event is actually thrown when the enter button is pressed and I'm able to get the callback in my callback method. My problem is that the enter button's functionality of virtually clicking a button still goes through, despite purposely not skipping the event (which would forward on the event). Since this is happening, and I'm sure my callback method is not forwarding the event along (I've tested this by capturing characters going to a text box) I suspect that the enter button throws an additional event that I'm not capturing. I've tried binding and capturing the additional following events to prevent the "virtual click" from the enter button:
parent.Bind(wx.EVT_TEXT_ENTER, self.CharInputCallback)
parent.Bind(wx.EVT_KEY_UP, self.CharInputCallback)
parent.Bind(wx.EVT_KEY_DOWN, self.CharInputCallback)
Yet when I press enter, the button in focus is still clicked. To summarize, is there an additional event being thrown when I press the enter button? If so, which event in particular is "virtually clicking" the button? Most forums I've found have discussed how to recognize when the enter button is pressed, but I want to recognize it and disable it's default action when a button is in focus.
I tried binding all those events to different handlers and I also bound EVT_BUTTON. It appears that EVT_BUTTON always fires BEFORE the key and char events do. If you don't want your button to be clicked, then you'll probably have to either disable it, use a different widget (maybe one of the generic buttons) or create your own. I would also ask on the wxPython mailing list to see if they have any suggestions.
The only way to order the events in wxPython that I'm aware of is to use wx.CallAfter or wx.CallLater. I'm not sure how you'd use that in this context though.
The event that causes enter to click a button is the key up event. My code for my callback was messed up slightly. Capturing the key up event and not skipping it prevent the enter button from clicking a button in focus. On Windows 7 anyways.
I am making application using silverlight.Here i want to move line on screen continuously on left and right arrow key pressed. In silverlight application there is facility of RepeatButton but i am not getting how to use it. Please help me if there is any solution on that.Thanks in advance.
An easier method would be to have (bool) flags like "keyLeftPressed" and "keyRightPressed". Then, on a specific tick (from a DispatchTimer possibly), check if the flags are set and take appropriate action. Finally, use four events to set the condition of the two flags: left key pressed, left key released, right key pressed, right key released.
I need to subclass a VB6 form so that if the user hits the [ALT] key while left clicking the title/caption bar, I can do something custom (show dialog box, file io, whatever).
So far, I have been able to do the subclassing in my NewWndProc() to correctly trap the WM_NCLBUTTONDOWN message when wParam = HTCAPTION, but I don't know how to trap the [ALT] key at the same time.
I have used the SPY utility a bit to check for messages, but I still can't solve this. Thanks for any help.
Update:
Looks like I may have to use mouse and keyboard hooks?
As it's not sent as part of the message. but you can call GetKeyState(VK_MENU) to get whether it's pressed or not.
I have a form with a progress bar and a cancel button which is displayed as a process runs. The buttons "Cancel" property is set to true so pressing escape, cancels the process.
But, as the button is the only control on the form capable of taking the focus, should the user inadvertently press enter (or space bar) while the process is running it will be cancelled.
I have prevented the Space Bar from working by setting KeyPreview to true (on the form) then setting KeyAscii to 0 but this approach deson't seem to work for the enter key as the button click event fires first.
I've tried setting the button's TabStop property to "false" - no change.
In my opinion, the Enter key should activate the cancel button. Or are you requiring the user to reach out for the mouse? why?
I suggest adding just a confirmation dialog after the user cancels the operation, so if anyone accidentally presses the Enter key have the chance to resume saying 'no, I don't want to cancel'.
But as a user I would be annoyed if the Cancel button has the focus and I can't activate it pressing the Enter key on my keyboard.
My 2 cents
Add a default button with size 1x1, no caption, no border, etc. Make a handler for it that does nothing. The Escape key will still do a cancel as it does now.