From: Kuldeep Mynampati on 20 May 2010 11:28 Hi All, I have created a rectangle using imrect function and assigned Text string as 1 using Text function. Once created the text with the positions are fixed. My problem is , I would like the Text string/label move along the rectangle when it is dragged. Could you please help me in this? With Regards, Kuldeep
From: Walter Roberson on 20 May 2010 14:39 "Kuldeep Mynampati" <mynampatikuldeep(a)gmail.com> wrote in message <ht3ke4$dqu$1(a)fred.mathworks.com>... > I have created a rectangle using imrect function and assigned Text string as 1 using Text function. Once created the text with the positions are fixed. My problem is , I would like the Text string/label move along the rectangle when it is dragged. I am not clear on what is being dragged: do you want to be able to drag the text into a new position, or do you want the text to stay at a certain position relative to the rectangle with the rectangle is dragged? If you want the text to stay at a certain position relative to the rectangle, you *might* be able to use linkprop(), but I think you might have a bit of trouble because you do not want the text to be at the lower-left of the rectangle.
From: Kuldeep Mynampati on 1 Jun 2010 10:18 Hi Walter, Thanks for your reply. I am sorry I could not reply back immediately. You are right. I want my Text to stay in a certain position relative to the rectangle with the rectangle when dragged. I don't mind my text is either at the lower left of the rectangle, as long as text is relative to rectangle. Can you send me a sample code for the linkprop() menthod? With Regards, Kuldeep "Walter Roberson" <roberson(a)ibd.nrc-cnrc.gc.ca> wrote in message <ht3vk8$4r4$1(a)fred.mathworks.com>... > "Kuldeep Mynampati" <mynampatikuldeep(a)gmail.com> wrote in message <ht3ke4$dqu$1(a)fred.mathworks.com>... > > > I have created a rectangle using imrect function and assigned Text string as 1 using Text function. Once created the text with the positions are fixed. My problem is , I would like the Text string/label move along the rectangle when it is dragged. > > I am not clear on what is being dragged: do you want to be able to drag the text into a new position, or do you want the text to stay at a certain position relative to the rectangle with the rectangle is dragged? If you want the text to stay at a certain position relative to the rectangle, you *might* be able to use linkprop(), but I think you might have a bit of trouble because you do not want the text to be at the lower-left of the rectangle.
From: Walter Roberson on 1 Jun 2010 10:54 Kuldeep Mynampati wrote: > You are right. I want my Text to stay in a certain position relative to > the rectangle with the rectangle when dragged. I don't mind my text is > either at the lower left of the rectangle, as long as text is relative > to rectangle. Can you send me a sample code for the linkprop() menthod? Darn, the Position property for text() is an [x, y, z] vector rather than an [x, y, w, h] vector, so they cannot be linked. Okay, what might work is creating a hgtransform() object and parenting the rectangle and text in the object and setting the HitTest of the rectangle and text to 'off'. Then you would likely have to create a ButtonDownFcn for the hgtransform() that implemented dragging by invoking set(HgTransformObject, 'Matrix', makehgtform('translate',[x, y, 0])) or something fairly similar. See http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hgtransform.html
|
Pages: 1 Prev: uitable - 'logical' - checkboxes Next: Slider implementation problem |