Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:09:36+00:00 2026-06-02T02:09:36+00:00

I use a dhtml (midas) editor as a html editor in my web application,

  • 0

I use a dhtml (midas) editor as a html editor in my web application, what I want to do is get a focused cursor in this html editor follow the mouse, is there a way to do that?

Added Example:
I want cursor in textarea follow the mouse so if you have a big text in your textarea and you are going over it with mouse, cursor (text cursor) should follow the mouse, like this:

“This is an ex|ample text” – if mouse is over “example” word and between x and a, text cursor (|) should be focused there but when I move mouse on for example “text” cursor | should be between letters where mouse is currently located.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:09:38+00:00Added an answer on June 2, 2026 at 2:09 am

    Ok I found the solution using Ext.util.TextMetrics, first I get position of every character in editor, then I compare that to mouse cursor position and then update midas selection based on given character from charNum array

    htmlEditor.getEl().on('mousemove', function(e)
    {   
        var charNum = {},
            text = htmlEditor.getValue(),
            fWidth = htmlEditor.getWidth();
    
        var textMetrics = new Ext.util.TextMetrics(htmlEditor.getEl(), htmlEditor.getWidth());
    
        for(var n=0;n<text.length;n++)
        {
            var dat = text.substring(0, n)
            var width = textMetrics.getWidth(dat);
            var height = textMetrics.getHeight(dat);
    
            if(width > fWidth)
            {
                var mult = Math.ceil(width/fWidth)
                var width = width % fWidth;
                height = height*mult;
            }
    
            charNum[n] = [width, height];
        }
    
        //console.log("charNum: "+charNum.toSource());
    
        var mX = e.getX();
        var mY = e.getY();
    
        var cXY = htmlEditor.getEl().getXY();
        var cX = cXY[0];
        var cY = cXY[1];                    
    
        var x = mX-cX-20;
        var y = mY-cY;
    
        //console.log("fin xy: "+x+' '+y);
    
        var n = -1;
        var z = 0;
        for(key in charNum)
        {
            if(charNum[key][0] > x && charNum[key][1] > y) 
            {
                n = key-1;
                break;
            }
            n++;
            z++;
        }
    
        if(x < 0 && y < 14) n = -1; 
    
    
        if(n == (z-1) && n != -1)
        {
            n++;
        }
    
        var selection = htmlEditor.win.getSelection();
    
        range = selection.getRangeAt(0);
        range.selectNodeContents(htmlEditor.getEditorBody());
        range.collapse(true);
        for(var x=0;x<n;x++)
        {
            selection.modify("move", "forward", "character");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate Dhtml menus. but i want to use a tool. does
We currently use the DHTML Window widget from: http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm Is there a jquery alternative
use this website a lot but first time posting. My program creates a number
Use case: I've just entered insert mode, and typed some text. Now I want
I know of various ways to dynamically alter web pages' typeface properties via JS/DHTML,
I'm going to use that template engine LTP . There is not so much
languages used: html, javascript/jquery, and php 5.2 So I created this function that onclick
Of the following: HTML, XHTML , DHTML which one is the present standard? Which
I have a asp.net application, which used html templates to generate content and sends
I haven't used HTML in JTextPane before and playing with this today. I come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.