Get the Coordinates of a Character in a TextArea

Is there a way to determine what the coordinates of a given
character are in a TextArea control? One project I'm working on
presents a chunk of text cut off at some number of characters,
followed by a LinkButton control (e.g., to view "more"), and I'm
having trouble figuring where to place the LinkButton control
without knowing the coordinates of the last visible character of
the TextArea. Anyone dealt with this one before?
Thanks in advance...
Chris

Hm, thanks, but that just places the LinkButton next to the
TextArea control, beside and outside of it, not "inside" (or really
over) it, as my example should've implied.
I think I've found a workable solution -- see below, where
myCanvas is some Canvas control already defined in MXML somewhere,
and myText is a Text control already defined (and populated) as
well:
var numberOfLines:int =
myText.mx_internal::getTextField().numLines;
var lineMetrics:TextLineMetrics =
myText.getLineMetrics(numberOfLines - 1);
var targetX:int = lineMetrics.width + 10;
var targetY:int = (numLines - 1) * lineMetrics.height;
var myLinkButton:LinkButton = new LinkButton();
myLinkButton.label = "More...";
myCanvas.addChild(myLinkButton);
Still testing, but TextLineMetrics seems to have done the
trick.
If anyone has a better approach, let me know! Thanks much.

Similar Messages

  • How to get the coordinate of any character in just a single text frame?

    I am using Illustrator CS5. Better solutions in c# language.

    Hi,
    According to your description, my understanding is that you want to get the groups name of a specific user using Client Object Model PowerShell in SharePoint 2010.
    We can loop the site group collection and the users in each group and then check if the user exists in the user collection.
    ClientContext clientContext = new ClientContext("http://sp/sites/mysite");
    GroupCollection collGroup = clientContext.Web.SiteGroups;
    clientContext.Load(collGroup);
    clientContext.ExecuteQuery();
    User usr = clientContext.Web.EnsureUser(@"contoso\administrator");
    clientContext.Load(usr);
    clientContext.ExecuteQuery();
    foreach (Group group in collGroup)
    UserCollection collUser = group.Users;
    clientContext.Load(collUser);
    clientContext.ExecuteQuery();
    foreach (User user in collUser)
    if (user.LoginName==usr.LoginName)
    Console.WriteLine(group.Title);
    Console.ReadKey();
    For PoweShell command, you can convert the code above to PowerShell Command.
    Here is a detailed article for your reference:
    https://msdn.microsoft.com/en-us/library/ee538244%28v=office.14%29.aspx?f=255&MSPPError=-2147217396
    Thanks
    Best Regards
    Jerry Guo
    TechNet Community Support

  • PhotoShop Automation PlugIn: How do I get the coordinates of a polygonal selection?

    Hi.
    I try to get the coordinates out of a selection, but I can't find out how to do that.
    I tried to convert the selection into a path and get the coordinates from the path. That doesn't work either.
    Can somebody give me a list of parameters inside the action descriptor of keyPathContent in classPath? I assume that the point infos are located there...
    Thanx in advance,
    Christian

    found the answer myself. It might be helpfull to others.
    btn.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent e) {
    Rectangle ret = btn.getBounds();
    double y = ret.y + ret.getHeight();
    pop.show((Component) e.getSource(), ret.x, (int)y);
    }

  • How to get the coordinate of a cell in the jtable?

    How to get the coordinate of a cell in the jtable?
    How to get the point of a cell in the jtable?
    Thanks for help!

    getCellRect(...);

  • Getting the coordinates of an overlayed rectangle or point

    I have drawn a rectangle or point on an image using the Tools and I now want to get the coordinates of the rectangle or point I have just drawn. How do I do this?

    bep -
    To do this, use the Regions property on the CWIMAQViewer object, and assign it into a variable of the type of the ROI (in this case, a rectangle). Here's an example:
    Dim rect As CWIMAQRectangle
    Set rect = CWIMAQViewer1.Regions(1)
    The rect variable should now contain the dimensions of the rectangle drawn.
    Let me know if you have problems with this. Thanks!
    Greg Stoll
    IMAQ R & D
    National Instruments
    Greg Stoll
    LabVIEW R&D

  • How can I get the coordinate in the layer coordinate system while doing the iterate?

    I found that the position(x,y) the iterate function tell me is not right sometimes.
    Actually,it happens when the top of the layer is negative. The "y"is in the comp coordinate system(maybe?) but not the layer.In another word, the position with y=0 is not the top.
    More specifically, I have got the color map of a layer. I am able to get the color of any pixel in the layer. But I can't set the color one for one when I use "iterate",because there is an offset.
    Am I supposed to get the offset? Is there any way to access the whole layer directly if I use iterate function?

    so indeed it's the offset at play.
    AE will diminish the buffer at 20% increments, and not for each pixel that
    goes out of sight. it's not really in relation to the upper left corner,
    it's all about what part of your layer buffer is out of sight.
    there's also an "iterate offset function". check it out. perhaps it will
    save you some trouble.
    On Fri, Dec 19, 2014 at 2:45 PM, Hinanawi Tenshi <[email protected]>

  • SDO_ORDINATES how to get the coordinates?

    Hello,
    how can i get the individual x1,y1 and z1 coordinates of a box? when i use in an sql statement sdo_ordinates i just get an object sdo_ordinate_array. But how can i filter out the coordinates? To explain what i want to do here a pseudocode sql-statement:
    select min(v.shape.sdo_ordinates.x1),min(v.shape.sdo_ordinates.y1),min(v.shape.sdo_ordinates.z1),max(v.shape.sdo_ordinates.x1),max(v.shape.sdo_ordinates.y1),max(v.shape.sdo_ordinates.z1) from veith.voxel v
    Is there a way to get an sql-statement that gives me the min and max x1,y1 and z1 from a table and also a statement where i get the x1,y1 and z1 value from all tableentries? For any help thanks in advance.
    Greetings,
    Markus Veith

    Markus,
    If you are using 9i there are two functions: sdo_geom.max_mbr_ordinate and sdo_geom.min_mbr_ordinate which will return either the min or max ordinate values in a layer.
    If you are using 8i, you will have to write a sql block or procedure to compare the x ordinates or y ordinates and retrieve the min or max values.
    Hope that helps.
    Dave
    David R. Miller
    Michael Baker Jr., Inc.
    3601 Eisenhower Avenue
    Alexanria, VA 22304
    [email protected]
    www.mbakercorp.com

  • Getting the coordinates of 1 bufferedimage inside another buffered image

    hi, i'm kinda new to this.
    is there a way to get the starting x and y coordinates of 1 bufferedimage inside another bufferedimage
    let's say this is bufferedimage 1
    http://img293.imageshack.us/i/oracle.png/
    and this is bufferedimage2
    http://img38.imageshack.us/i/buffered2.png/
    i would like a method to return the x and y coordinates of image1 inside image2
    is there anyway to approach this?
    or was there a prewritten method?
    thanks

    bep -
    The problem is that the two rectangles have points in common. When the CWIMAQVision.RegionsToMask is done, it sets any point that is in any region to a non-zero value, and all other points to 0. So, when the CWIMAQVision.Label is done, it sees one big rectangle of non-zero values, and labels that (and so the CWIMAQVision.Quantify sees the one rectangle as well).
    The easiest way around this problem (if the rectangles must have points in common) is to only make one region active at a time, so CWIMAQVision.RegionsToMask will only use that region to create the mask image, and then call CWIMAQVision.Quantify twice. So, the code would look like this:
    Set pMaskImage = New CWIMAQImage
    pMaskImage.Type = cwimaqImageTypeU8
    Me.CWIMAQViewer1.R
    egions(1).Active = True
    Me.CWIMAQViewer1.Regions(2).Active = False
    Me.CWIMAQVision1.RegionsToMask pMaskImage, Me.CWIMAQViewer1.Regions
    Me.CWIMAQVision1.Label pMaskImage, pMaskImage, avgPixelVal
    Me.CWIMAQVision1.Quantify Me.CWIMAQViewer1.Image, globalReport, regionsReport, pMaskImage
    dblROImean = regionsReport.Item(1).Mean
    Me.CWIMAQViewer1.Regions(1).Active = False
    Me.CWIMAQViewer1.Regions(2).Active = True
    Me.CWIMAQVision1.RegionsToMask pMaskImage, Me.CWIMAQViewer1.Regions
    Me.CWIMAQVision1.Label pMaskImage, pMaskImage, avgPixelVal
    Me.CWIMAQVision1.Quantify Me.CWIMAQViewer1.Image, globalReport, regionsReport, pMaskImage
    dblSurrROImean = regionsReport.Item(1).Mean
    Let me know if this gives you problems.
    Greg Stoll
    IMAQ R & D
    National Instruments
    Greg Stoll
    LabVIEW R&D

  • How do I get the coordinates of the text block (TextFrame) help me please!

    Dim myApp As New Illustrator.Application
    Dim myDoc As Illustrator.Document
    myDoc = myApp.ActiveDocument
    Dim textRef = myDoc.TextFrames.Add
    For Each ArtPageItems In myDoc.PageItems
    If TypeName(ArtPageItems) = "TextFrame" Then
    '========It is necessary to obtain the coordinates of the text block and move closer to the object (ie the text)============
    Else
    End If
    Next

    Hi Todd, you're welcome, please explain better, I don't understand the question.
    are you trying to "move" a textframe (Dim textRef = myDoc.TextFrames.Add) closer to other text frames? or do you want to "zoom" to this textframe?

  • How can I get the coordinates to draw a line?

    Hi,
    I want to draw a line. Here is a part of my Quell-code.
    public class Map extends JFrame {
    public Map() {
    super("Map");
    setSize(340, 340);
    MapPane map = new MapPane();
    getContentPane().add(map);
    class MapPane extends JPanel {
    public void paintComponent(Graphics comp) {
    Graphics2D comp2D = (Graphics2D)comp;
    comp2D.drawLine(0,0,340,340);
    Now, the line begins exactly top left in the edge, but ends not exactly down right in the edge of my Frame. Is there any possibility to determine the exact coordinates of the frame. I thought, if the size of the window is set by the setSize-Method to (340,340), the line ends exact
    in the edge (down right). See: comp2D.drawLine(0,0,340,340).
    Can somebody give me a piece of advice, please?
    Thanks, joletaxi

    Have you tried the getWidth() and getHeoght() methods to determine how long the line should be?

  • Getting the coordinates of dynamically created objects

    i have created 3 movie clips via actionscript and given them
    instance names of cS_1, cS_2, and cS_3. however, i can't manage to
    trace their x coordinates. i know i gotta do something with
    getChildByName but i'm really stuck and can't figure it out. Could
    someone please explain to me what i have to do like explaining to
    an 8 year old. Thank you!
    Here's the code:

    To use the getChildByName method you want to cast a MovieClip
    variable to capture a reference to it, as in:
    var cs1:MovieClip = this.getChildByName(cs_1);
    trace(cs1.x);

  • Help! Getting the index of a Character from the Characters collection

    so, in a script i need to remove the text from the begining of the paragraph until the first tab (or dot or colon or "something") charater as simple and as fast as posible.
    i was hoping for something like
    myText=myParagraph.characters.itemByRange(0,"\t");
    myText.remove();
    Ofcourse i can use grep, but it has it's problems, and i was hoping i don't have to (especialy since the script will have to do this for 400+ times.
    Any help?

    Vamitul
    I don't know if that's the way do go about it but this is what you are looking for.
    myParagraph=app.selection[0].paragraphs[0];
    myText=myParagraph.characters.itemByRange(0,myParagraph.contents.toString().indexOf("\t"));
    myText.remove();
    To delete until the tab not including it use myText=myParagraph.characters.itemByRange(0,myParagraph.contents.toString().indexOf("\t") -1);
    Trevor
    Message was edited by: ~ Trevor ~

  • How to get the x1,y1 and z1 coordinates out of an sdo_geometry object?

    Hello,
    i have stored several boxes into an sdo_geometry object like the following:
    mdsys.sdo_geometry(3003,null,null,
    mdsys.sdo_elem_info_array(1,1003,3),
    mdsys.sdo_ordinate_array(x1,y1,z1,x2,y2,z2)
    now i would like to get the x1,y1,z1 coordinates from the boxes. how can i get them with a simple sql-statement?
    When i do "SELECT v.shape.sdo_ordinates ..." then i get a sdo_ordinate_array. But how can i get only the first coorinates?
    I know how it works to get x1,y1 and z1 over a java-prog. But i want to get them with a sql-statement as i also want to get the min and max x1,y1,z1.
    Hope there is anybody that can help me. Thanks in advance.
    Markus Veith

    You can get coordinates from an SDO_POINT_TYPE as follows:
    SELECT      t.GEOMETRY.SDO_POINT.x,t.GEOMETRY.SDO_POINT.y
    FROM      TABLE T
    (where geometry is the geometry column and table is the geometry table, note
    that a table alias must be used.)
    Getting the coordinates from the SDO_ORDINATES is a little trickier.
    You'll need to use a loop in PL/SQL, eg:
    SET SERVEROUT ON
    DECLARE
    i number;
    j NUMBER;
    BEGIN
    FOR sel IN (SELECT <geom_column> FROM <geom_table> WHERE ROWNUM < 10) LOOP
    i := 1;
    while i < sel.<geom_column>.sdo_ordinates.count LOOP
    j:= sel.GEOMETRY.sdo_ordinates(i);
    dbms_output.put_line(j);
    i := i + 1;
    j:= sel.GEOMETRY.sdo_ordinates(i);
    end loop;
    dbms_output.put_line(j);
    END LOOP;
    END;
    This will print the SDO_ORDINATES to the SQLPLUS screen, put a WHERE clause to reduce output.
    To use these values in a query, put them in a cursor.

  • Get instantly the coordinate of end and start point of line, when moving it

    hello guys,
    i'm just wondering on how to get the coordinate of Start and End point of a line when I'm using PathWrangler wrangler = new PathWrangler(this); this latter allows the paint components to be dragged, so i want to get instantly the coordinate of the Start and End point of the line.
    MY AIM IS: i want whenver an intersection between 2 lines occur( the line is being dragged so intersection may occur between the two lines) i want to draw a circle having as center the intersection of the 2 lines.
    i managed to write a code that draws 2 lines and a circle having a center the intersection of both lines. here is the code:
    import java.awt.*; 
        import java.awt.event.*; 
        import java.awt.geom.*; 
        import java.util.*; 
        import java.util.List; 
        import javax.swing.*; 
        import javax.swing.event.MouseInputAdapter; 
        public class SDRx extends JPanel { 
           List<Path2D.Double> paths = new ArrayList<Path2D.Double>(); 
           PathWrangler wrangler = new PathWrangler(this);
           Point p1= new Point(120,150);
           Point p2= new Point(140,210);
           Point p3= new Point(120,150);
           Point p4= new Point(110,230);               
            Line2D.Double l1=new Line2D.Double(p1,p2);
           Line2D.Double l2=new Line2D.Double(p3,p4);
            Point2D.Double inter= intersection(l1.getX1(),l1.getY1(),l1.getX2(),l1.getY2(),l2.getX1(),l2.getY1(),l2.getX2(),l2.getY2());
           Ellipse2D.Double ell= new Ellipse2D.Double(inter.getX()-25,inter.getY()-25,50,50);
           public SDRx() { 
               paths.add(wrap(l1));
               paths.add(wrap(l2));
               paths.add(wrap(ell));             
           private Path2D.Double wrap(Shape s) { 
               return new Path2D.Double(s); 
           protected void paintComponent(Graphics g) { 
               super.paintComponent(g); 
               Graphics2D g2 = (Graphics2D)g; 
               g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
                                   RenderingHints.VALUE_ANTIALIAS_ON); 
               g2.setPaint(Color.blue); 
               for(int j = 0; j < paths.size(); j++) { 
                   g2.draw(paths.get(j)); 
           public void transformPath(Path2D.Double path, AffineTransform at) { 
               path.transform(at); 
               repaint(); 
            public Point2D.Double intersection(double x1,double y1,double x2,double y2, double x3, double y3, double x4,double y4) {
          double d = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4);
          if (d == 0) return null;
          double xi = ((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/d;
          double yi = ((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/d;
        return new Point2D.Double(xi,yi);
           public static void main(String[] args) { 
               JFrame f = new JFrame(); 
               f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
               f.add(new SDRx()); 
               f.setSize(400,400); 
               f.setLocation(100,100); 
               f.setVisible(true); 
       }any help is appreciated.
    10x

    OK guys i'm sorry for before i said few wrong things about PathWrangler wrangler = new PathWrangler(this); i thought it was in the java library.
    anyway here is the full code( i got it few weeks ago(with few modidfication) from somwhere, u can google it)
        import java.awt.*; 
        import java.awt.event.*; 
        import java.awt.geom.*; 
        import java.util.*; 
        import java.util.List; 
        import javax.swing.*; 
        import javax.swing.event.MouseInputAdapter; 
        public class SDRx extends JPanel { 
           List<Path2D.Double> paths = new ArrayList<Path2D.Double>(); 
           PathWrangler wrangler = new PathWrangler(this);
           Point p1= new Point(120,150);
           Point p2= new Point(140,210);
           Point p3= new Point(120,150);
           Point p4= new Point(110,230);               
            Line2D.Double l1=new Line2D.Double(p1,p2);
           Line2D.Double l2=new Line2D.Double(p3,p4);
            Point2D.Double inter= intersection(l1.getX1(),l1.getY1(),l1.getX2(),l1.getY2(),l2.getX1(),l2.getY1(),l2.getX2(),l2.getY2());
           Ellipse2D.Double ell= new Ellipse2D.Double(inter.getX()-25,inter.getY()-25,50,50);
           public SDRx() { 
               paths.add(wrap(l1));
               paths.add(wrap(l2));
               paths.add(wrap(ell));             
           private Path2D.Double wrap(Shape s) { 
               return new Path2D.Double(s); 
           protected void paintComponent(Graphics g) { 
               super.paintComponent(g); 
               Graphics2D g2 = (Graphics2D)g; 
               g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
                                   RenderingHints.VALUE_ANTIALIAS_ON); 
               g2.setPaint(Color.blue); 
               for(int j = 0; j < paths.size(); j++) { 
                   g2.draw(paths.get(j)); 
           public void transformPath(Path2D.Double path, AffineTransform at) { 
               path.transform(at); 
               repaint(); 
            public Point2D.Double intersection(double x1,double y1,double x2,double y2, double x3, double y3, double x4,double y4) {
          double d = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4);
          if (d == 0) return null;
          double xi = ((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/d;
          double yi = ((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/d;
        return new Point2D.Double(xi,yi);
           public static void main(String[] args) { 
               JFrame f = new JFrame(); 
               f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
               f.add(new SDRx()); 
               f.setSize(400,400); 
               f.setLocation(100,100); 
               f.setVisible(true); 
       class PathWrangler extends MouseInputAdapter { 
           SDRx component; 
           AffineTransform at = new AffineTransform(); 
           final int S = 6; 
           Rectangle net = new Rectangle(S, S); 
           Path2D.Double selectedPath; 
           Point offset = new Point(); 
           boolean dragging = false; 
           public PathWrangler(SDRx sdr) { 
               component = sdr; 
               component.addMouseListener(this); 
               component.addMouseMotionListener(this); 
           public void mousePressed(MouseEvent e) { 
               Point p = e.getPoint(); 
               net.setLocation(p.x-S/2, p.y-S/2); 
               List<Path2D.Double> list = component.paths; 
               for(int j = 0; j < list.size(); j++) { 
                   Path2D.Double path = list.get(j); 
                   // Use the contains method to detect RectangluarShapes 
                   // and the intersects method with net to detect lines. 
                  if(path.contains(p) || path.intersects(net)) { 
                       selectedPath = path; 
                       Rectangle r = selectedPath.getBounds(); 
                       offset.x = p.x - r.x; 
                       offset.y = p.y - r.y; 
                       dragging = true; 
                       break; 
           public void mouseReleased(MouseEvent e) { 
               dragging = false; 
           public void mouseDragged(MouseEvent e) { 
               if(dragging) { 
                   int x = e.getX() - offset.x; 
                   int y = e.getY() - offset.y; 
                   Rectangle r = selectedPath.getBounds(); 
                   at.setToTranslation(x-r.x, y-r.y); 
                   component.transformPath(selectedPath, at);
       }  10x

  • The coordinate of drawString()

    Guys,
    If I use Graphics2D to draw a String, how can I get the coordinate of the last character?
    For example, If I:
    Graphics2D comp2d= new Graphics2D (comp);
    comp2d.drawString("Hello the world", 100, 100 );
    How can I get the coordinate for the letter "d" as in "world"?
    Thanks in advance!

    try using the FontMetrics class
    it has methods like stringWidth() and charWidth()
    these would be helpful

Maybe you are looking for

  • Problem in opening MS Word doc from CRM back-end.

    Hi All: I have a MS Word document stored in my CRM system which opens by passing a transaction number as input. When we try to preview the word doc it opens properly from back-end. But the real problem exists when i'm trying to open it from my web-dy

  • Facing issue when LDAPSync is enabled for OIM-AD integration with SSL enabled

    Hi We are performing LDAPSync for OIM AD real time sync.We have done all configuration as per oracle documentation on LDAPSync for OIM 11gR2 : http://docs.oracle.com/cd/E27559_01/integration.1112/e27123/oid_oim.htm The OIM environment we tested is th

  • Dynamic excel name for Excel Destination in SSIS

    I have a for each loop container which executes for each advertise rid.For each advertiser it runs a sql query and exports to an excel file.there are seven advertisers and hence there will be seven excel reports.But my requirement is to name them acc

  • Exif maker note gets lost

    I have a custom camera that saves some information in the exif maker notes (calibration data). The output is in normal JPEG. I can see the custom data on all original file. But whenever a file goes through Adobe Lightroom 5 or Photoshop CS6, the make

  • Career:Shift from ABAP to BW-Netweaver after business object takeover

    Hi all, Am an ABAPer  with one and half years of experience.I will be thankful if sombody will tell me If its appropriate to move into BW-Netweaver as i heard BUSINESS OBJECT is likely to replace BW-Netweaver  in near future. Thanks. Edited by: sande