enable_editclick_no​tification

Version 1.2.0.0 (1,56 ko) par David
Causes the currentobject property of a figure to be properly updated when an edit field is clicked.
176 téléchargements
Mise à jour 14 fév. 2012

Afficher la licence

format:
enable_editclick_notification(figure_handle)

When a user clicks an edit field in a matlab figure, the currentobject property of the figure is not updated immediately. Only after the user has pressed a key is the currentobject property of the figure updated to the edit field handle.

Therefore, when processing a key press, it is often unclear whether the key press should activate a hotkey or whether it is meant as input to an edit field. For example, when the user presses the right arrow key in a movie player, is the intention to advance a frame or has an edit field with a numerical value been clicked? It is not clear.

However, after calling this function with a figure handle as an input, any future clicks on an edit field will cause the currentobject property of the figure to be updated, even before the user has pressed a key. Any existing callbacks of the figure or edit fields will work as normal.

To accomplish this, the function modifies several callbacks: the buttondownfcn of the edit fields in the figure, and the figure's windowbuttondownfcn. By setting the edit fields' enable property to inactive, we can intercept clicks, which we then respond to in the appropriate way in addition to temporarily enabling the edit field. The original callbacks will be executed as normal, so long as they were of standard form (e.g. fcn(hObject, eventdata)). When the user clicks the figure background or executes an edit field callback, the edit fields are set back to inactive before the normal callback is executed.

Note that after calling this function, edit fields with the enable property set to inactive will now essentialy be on, while the off functionality will be unchanged. Edit fields' enable property should never be set programmatically to on after his function has been called. An invisible text style uicontrol will be created for the purpose of removing focus from edit fields when need be.

I tested this on windows, not sure about mac and linux. Feedback is welcome!

Citation pour cette source

David (2026). enable_editclick_notification (https://fr.mathworks.com/matlabcentral/fileexchange/34060-enable_editclick_notification), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2010a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et MATLAB Answers
Version Publié le Notes de version
1.2.0.0

fixed another typo

1.1.0.0

fixed typo in description

1.0.0.0