Comments on: Figure keypress modifiers https://undocumentedmatlab.com/blog_old/figure-keypress-modifiers Charting Matlab's unsupported hidden underbelly Thu, 02 May 2024 08:00:01 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Erichttps://undocumentedmatlab.com/blog_old/figure-keypress-modifiers#comment-511699 Mon, 25 Apr 2022 12:26:16 +0000 https://undocumentedmatlab.com/?p=6059#comment-511699 this save me a lot of time, thank you very much!

]]>
By: Heikohttps://undocumentedmatlab.com/blog_old/figure-keypress-modifiers#comment-418846 Thu, 01 Feb 2018 09:27:36 +0000 https://undocumentedmatlab.com/?p=6059#comment-418846 On a not directly related note, I found out that if you create a figure with an edit control and you enter the ‘@’ symbol, MatLab closes like it would with the CTRL+Q shortcut. If MatLab is configured to not ask for confirmation, it simply closes without warning.

Mathworks explains this with the CTRL+Q event forwarded from the figure to the command window. This behavior seems to exist since R2014b. MatLab doesn’t seem to make a distinction between the modifiers (‘@’ is CTRL+ALT+Q). The official workaround is to populate the file menu either by clicking on it, or programmatically like this:

f = figure;
filemenufcn(f, 'FilePost');
uicontrol(f,'Style','edit')

Alternatively, the confirmation for closing should be activated. Once cancelling the confirmation, the ‘@’ symbol can be used without the effect.

IMHO, this is a critical bug for GUIs using edit fields for email addresses and the like, because data loss is very likely.

]]>
By: Daniel Castanohttps://undocumentedmatlab.com/blog_old/figure-keypress-modifiers#comment-405159 Fri, 21 Apr 2017 07:42:54 +0000 https://undocumentedmatlab.com/?p=6059#comment-405159 This info has made may life so much easier in the past months…. thanks!

I’m wondering if the Figure class has some equivalent property for the behaviour of the mouse, i.e., a property that expresses if (in the moment of reading the property) the mouse is pressed, and which button.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/figure-keypress-modifiers#comment-361418 Thu, 12 Nov 2015 22:34:06 +0000 https://undocumentedmatlab.com/?p=6059#comment-361418 When the window does not have focus then it should not handle any key-press event. It is the responsibility of the window that does have the focus to process it.

]]>
By: julienhttps://undocumentedmatlab.com/blog_old/figure-keypress-modifiers#comment-361410 Thu, 12 Nov 2015 20:44:52 +0000 https://undocumentedmatlab.com/?p=6059#comment-361410 Actually, when figure has not the focus, java ‘KeyPressed’ event is not triggered. So, impossible to know when the clic is done which modifiers are pressed…

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/figure-keypress-modifiers#comment-361223 Tue, 10 Nov 2015 14:35:05 +0000 https://undocumentedmatlab.com/?p=6059#comment-361223 You can use the KeyPressedCallback property at the Java-frame level, then you don’t have any of these limitations.

]]>
By: julienhttps://undocumentedmatlab.com/blog_old/figure-keypress-modifiers#comment-361220 Tue, 10 Nov 2015 13:33:48 +0000 https://undocumentedmatlab.com/?p=6059#comment-361220 Indeed, this is convenient. However, when figure has not focus, ‘CurrentModifier’ property is not updated. So if you hold a modifier key when figure has not focus and you then clic in the figure, ‘CurrentModifier’ property is not correct. Do you know a way to fix this?

]]>