hggroup of text() objects and contextmenu

-------------------------------------
THE SITUATION
-------------------------------------
I am creating text labels
h = text([.5 1],[.5 .5],{'hi','hello'});
plotedit on
which individually have a contextmenu that allow to change their text properties, e.g. try to right-click and change Font...
However, I'd like to keep the same contextmenu for a hggroup() of text() objects.
hg = hggroup;
set(h,'Parent',hg)
The text properties are not reachable from the context menu associated to hggroup().
-------------------------------------
THE QUESTION
-------------------------------------
Is there a way to have a contextmenu for the hggroup object with the menus for the text properties without recreating it manually with all the callbacks? For instance, scatter() creates such a contextmenu
figure
load seamount
scatter(x,y,5)
plotedit on
you can right click and change some properties of all children of the hggroup.
I have the feeling the solution already exists but it's undocumented and well hidden.
I've been looking into $MATLABROOT\toolbox\matlab\specgraph, graph2d, graphics to no avail.
I suspect that the various schemas might play a role, i.e. what if I define a schema for text()?
PS. Let me know if I didn't express myself clearly.

6 commentaires

Jan
Jan le 10 Sep 2012
I do not get the problem. Why not appending the context menu to the children of the hggroup?
Oleg Komarov
Oleg Komarov le 10 Sep 2012
I am trying to right click on any of the children and modify a property with a context menu for all of the children. Will your suggestion work in that way?
Oleg Komarov
Oleg Komarov le 10 Sep 2012
Is there any way I can access the "inbuilt" contextmenu for the text label and copy-paste it to the hggroup?
Jan
Jan le 10 Sep 2012
I don't know. But my trials with R2009b seem to show, that the UIContextMenu of the hggroup is not triggered by a right-click on the text objects. As far as I can see creating a new context menu and attach it to all children of the hggroup should be able to do everything possible.
Oleg Komarov
Oleg Komarov le 10 Sep 2012
I quickly tested it and I like so far the behavior. I will play with it a bit longer to see if the solution satisfies my objectives (which are still not completely determined).
Oleg Komarov
Oleg Komarov le 5 Oct 2012
At the end I did not find a way around, and recreating the whole contextmenu takes quite some time (which is what I wanted to avoid).

Connectez-vous pour commenter.

Réponses (1)

Yair Altman
Yair Altman le 7 Jan 2013

2 votes

Oleg, you can simply reuse the localGetNonScribeScribeContextMenu() subfunction in %matlabroot/toolbox/matlab/graph2d/private/plotSelectMode.m. It is called by localWindowButtonDownFcn() in that same file whenever you right-click an object in plot-selection mode.
Whenever you right click an object in this mode, the standard scribe context-menu (which include all the text items that you need) is recreated and added to the bottom of the object's existing context-menu (if available).
So you can simply cut all the red tape and reuse the localGetNonScribeScribeContextMenu() code directly when you create the initial context-menu.

1 commentaire

Jan
Jan le 7 Jan 2013
Due to the name "localGetNonScribeScribeContextMenu" I would not use the term "simply" here ;-)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by