Unknown handles in uitree, mouse press callback
Show older comments
Dear my friend
I have a question about handles
I designed a GUI with a uitree, I decided to implement the mouse pressed call back which is one of the properties of uitree (javahandles) but handles is unknown by the callback.
This problem makes too many difficulties in my coding and actually stopped me from continuing the programming.
I really ask you how i can access thehandles in mouse pressed callback which is one of the events of the uitree (javahandles)?
Thanks in advance
2 Comments
Geoff Hayes
on 30 Sep 2016
hamid - you may need to post some of your code so that we can get a better idea as to what you have attempted and how the mouse press callback has been implemented. Have you used GUIDE to create your GUI?
hamid reza ranjbar
on 1 Oct 2016
Edited: Walter Roberson
on 1 Oct 2016
Answers (1)
Walter Roberson
on 30 Sep 2016
When you create a callback yourself, you need to pass in the handles structure. For example,
set(handles.AppropriateTagHere, 'SelectionChangeFcn', @(src, event) mySelectFcn(src, event, handles))
Note that when you do this, a copy of handles will be taken and it will always be that same copy that is passed to the function call, not being updated if you change data fields in handles. If your handles structure contains handles to graphics objects, then you will be able to see changes that happened to that object, as long as the handle to the graphics object remains valid.
2 Comments
hamid reza ranjbar
on 1 Oct 2016
Walter Roberson
on 1 Oct 2016
You did not happen to show the code in which you set mousePressedCallback to be used.
If you look at https://www.mathworks.com/matlabcentral/answers/215114-how-to-detect-double-click-with-mouse-on-a-tree-node they show there:
% MousePressedCallback is not supported by the uitree, but by jtree
set(jtree, 'MousePressedCallback', @mousePressedCallback);
You would alter that to
% MousePressedCallback is not supported by the uitree, but by jtree
set(jtree, 'MousePressedCallback', {@mousePressedCallback, handles});
and you would alter
function mousePressedCallback(hTree, eventData) %,additionalVar)
to
function mousePressedCallback(hTree, eventData, handles)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
