Change selected gui element in program

I am working on a GUI with two axes in it (as well as various other elements). I want to be able to both track the position of the mouse within the axes as well as register mouse clicks on the axes.
Tracking the mouse movement works fine, as does identifying the location of mouse clicks. However, once the mouse click is complete on an axis, tracking of the mouse position stops working. It seems that when the mouse click is carried out, the currently-selected object changes from the figure to the axis.
Is there a way to change the selection back to the figure in the script so it starts tracking mouse positions again? I want to do some actions with the button press using the axis's ButtonDownFcn callback function then return the selection back to the figure at the end of that function.

Answers (2)

I think this video and the answers/comments associated with it, will interest you:

2 Comments

I don't think this is what I am looking for. I wasn't clear in the original report, but I have multiple axes and various other elements I need to interact with. This GUI looks like it would work fine for a single axis, but I am not sure it would help with multiple ones. I have updated the question to be more clear.
If it can, could you please be more specific about how? I don't see anything in the answers that can help me with this case, but I may just be missing it.
I thought you might be interested in the idea of changing the callbacks as you push mouse buttons.

Sign in to comment.

In theory using figure() or setting the root current object property should return focus. In practice people generally report that that does not work until the callback is finished.
The work-around is to set hittest for the object off, and to use an undocumented call (whose name I forget, sorry) to figure out which object is underneath the cursor, and invoke the object's callback yourself so that focus is not given away.

1 Comment

Even with hittest off it still selects the axis when I right-click on it.

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Asked:

on 5 Jan 2012

Community Treasure Hunt

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

Start Hunting!