MATLAB: How detect the mouse PRESS of a pushbutton

guimousepresspushbuttonrelease

Hi,
I am currently working on a GUI and I need to detect the left mouse press (and release) of a pushbutton. Then I associate a callback for each event detected. For example: I Want to set a variable to 1 at the mouse press and to 0 at the mouse release.
I have allready explore: – UIcontrol 'Callback' property but it is active at the release mouse click.
– UIcontrol 'ButtonDownFcn' property which is active at the mouse press click but only with right mouse button or on 5-pixel border around the uicontrol).
– On the file exchange a function which allow to put Java's properties on uicontrol but it's very time consuming (1 minute for launching my GUI).
I want the two figure's properties 'WindowButtonDownFcn','WindowButtonUpFcn' but for a uicontrol (pushbutton).
If you execute the code below you can see at the mouse press, 'press' displaying in the console window and at the mouse release you can see 'release' in the console.
figure('WindowButtonDownFcn',@(obj,evt)disp('press'),...
'WindowButtonUpFcn',@(obj,evt)disp('release'));
I'm writting because I have no other idea to do this… So if anyone knows a way to help me, I would be very grateful!!

Best Answer

I find answer to my question using Java command which is recognized by matlab.