Keyboard's event considered like mouse's click on the GUI - matlab

I'm using GUI, I have 4 button in my GUI and my callback detect mouse and keyboard event.
Mouse event concerns click on button
Keyboard event concerns space press to play a .wav
When the position of mys cursor's mouse is on one of the 4 buttons, and I press space I've the following error
"Undefined function 'pushbutton4_KeyPressFcn' for input arguments of type 'struct'."
I didn't define any keyboard shortcut for the GUI's button, how can I avoid this error ?
Thanks !

Open the GUI in GUIDE.
Right click on the button and chose 'Property Inspector'.
Scroll down to the 'KeyPressFcn' field and delete the value.
Save the GUI and try again.

Related

Is there a way to dismiss hover window (the tooltip like thingy) when I press any key?

In typescript project I hover the mouse over types to find what it contains. Then pressing any key dismisses it.
However when I bring the same tooltip via keyboard, it does not dismiss untill I press escape.
Is there some settings to auto dismiss the tooltip when it is invoked by the keyboard ?
This will help a smooth learn and edit experience

Detect when Ctrl is pressed

I'm implementing a ctrl+click solution for links in a textview and am having trouble setting the cursor to a hand when Ctrl is being held. Right now I
set the cursor to a hand in mouse motion when mouse moves inside the textview and control is pressed and the mouse is on top of a link (I use TextTag to style the links, so I just check whether the text below the mouse has this tag.).
set the mouse cursor back to the text edit cursor otherwise
However, when the mouse is on top of the link and I press Ctrl (without moving the mouse) the cursor does not change. Clearly, no mouse motion was detected so this is the expected behavior. My problem is how to implement this. I tried adding a keypress handler to the textview, but
it only fires when the textview has focus. This is not always the case, since I might not click the textview before clicking the link.
event.get_state() only comes with CONTROL_MASK if other key is pressed as well.
I receive no information about the mouse cursor, so I end up not knowing where it is pointing inside the keypress handler.
How can I solve these issues so I can have a Ctrl+click solution that shows adequate cursor when Ctrl is being pressed? I can already solve it by considering only mouse motion. The problem is how to detect Ctrl being pressed and react accordingly without mouse motion.

Delphi Detect if mouse over form's close button

I want to detect if user clicked on close button on an inactive form inside my application. How can I detect if mouse hovering on form's close button so I can use that data when form is being closed?
You can send the Form's window a WM_NCHITTEST message, passing the mouse's screen coordinates in the lParam value. If the return value is HTCLOSE, the mouse is over the Close button.
However, just because the mouse is over the Close button does not guarantee that the user actually clicked on the button. For instance, the user could move the mouse over the button and then type Alt+F4 on the keyboard instead (or Alt+Space, arrow down to the Close option, and press Enter, which invokes the same action as Alt+F4).
Whether clicking on the Close button, or using a keyboard shortcut, the same WM_CLOSE message is sent to the window (triggering the Form's OnCloseQuery and OnClose events), and it does not report why the window is being closed.
If you need to differentiate, you can have your Form handle the WM_NCLBUTTONDOWN/WM_NCLBUTTONUP and WM_SYSCOMMAND window messages. When closing the window by clicking on its Close button, WM_CLOSE will be preceded by WM_NCLBUTTON... with the wParam set to HTCLOSE. When closing the window by keyboard shortcuts, WM_CLOSE will be preceded by WM_SYSCOMMAND with its wParam set to SC_CLOSE.

Replace a key for an external mouse

I have an external mouse which also register a HID keyboard in Device Manager. One of its button shows start menu. I want to replace it with mouse click. Since I also have an inbuilt keyboard I don't want to replace its start button. I want to replace start button from the external mouse
Try using the #InstallKeybdHook and look in the KeyHistory when you have pressed the button!
This can atleast tell you if your mouse button has the same virtual key code or scan code as the built-in keyboards key
This is a step by step guide http://ahkscript.org/docs/KeyList.htm#SpecialKeys

how to handle mouse click in powershell

I have and text box in and I want to clear the text box when the mouse click is happen , I am using PrimalForms to use powershell with GUI.
Put the code to clear the text box on the click event handler. For example, clicking button1:
$handler_button1_Click={
$textbox1.Text=''
}
Here's how to add the click event handler directly to button1 (without using PrimalForms):
$button1.add_Click( {$textbox1.Text=''})