enable_editclick_no​tification

Version 1.2.0.0 (1.56 KB) by David
Causes the currentobject property of a figure to be properly updated when an edit field is clicked.
176 Downloads
Updated 14 Feb 2012

View License

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!

Cite As

David (2024). enable_editclick_notification (https://www.mathworks.com/matlabcentral/fileexchange/34060-enable_editclick_notification), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Interactive Control and Callbacks in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

fixed another typo

1.1.0.0

fixed typo in description

1.0.0.0