Jump to content
  • Advertisement
Sign in to follow this  
Plerion

Windows Text Cursor Hotspot offset

This topic is 2034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all

 

While implementing selection using the mouse for my textbox i have realized, that the windows text cursor seems to have some offset from its center bar to the hotspot, its actually exactly 2px to the left. I can show you the problem with images:

 

Image 1: The cursor is at the position WM_MOUSEMOVE gives 0 and moving the mouse one pixel to the left makes it show the sizing cursor (so its out of the client area)

53368ca7b25c3_Cursor_Crop.png

 

As you can see the center bar of the cursor is clearly not at this point.

 

Image 2: The cursor is again at position 0, but this time its the default cursor

53368ce2e4dd8_Cursor2_Crop.png

 

This cursor correctly points to the beginning of the client area.

 

Is there a way to determine this offset? Is it the same for xp, vista, win7, win8? This seems to be a bit annoying in my opinion...

 

Greetings

Plerion

Share this post


Link to post
Share on other sites
Advertisement

Is there a way to determine this offset?

Yep. GetIconInfo.

 

The ICONINFO structure pointed to on return from that function provides the (relative) coordinates of the hotspot for a cursor.

 

FYI, this info easily found by googling for (of all things): "windows cursor hotspot" wink.png

 

Also just FYI: The onscreen cursor follows the mouse, whatever that cursor may be (IDC_ARROW, IDC_IBEAM, etc.). It can differ from the Windows caret position, which, for text input is commonly displayed as a blinking underscore or vertical line to let the user know where keyboard character input will be placed. You can see the difference by clicking in the Reply box on this page - a blinking vertical line caret appears in the edit box, but the cursor still follows the mouse.

Edited by Buckeye

Share this post


Link to post
Share on other sites

Hey Buckeye

 

I forgot to mention that: the hotspot is given with an x-value of 8, the center bar is in the monochrome bitmap at a pixel offset of 10, so its actually already wrong there. Considering that a particular user might have overriden the default text cursor in his system i cannot just look for the center bar in the bitmap as maybe someone has a different default text cursor.

 

Greetings

Plerion

Share this post


Link to post
Share on other sites

Hey Buckeye

 

I forgot to mention that: the hotspot is given with an x-value of 8, the center bar is in the monochrome bitmap at a pixel offset of 10, so its actually already wrong there. Considering that a particular user might have overriden the default text cursor in his system i cannot just look for the center bar in the bitmap as maybe someone has a different default text cursor.

 

Greetings

Plerion

 

I'm not at all sure what you mean by "its actually wrong there." If you mean it's not where you would like it to be, create your own cursor with a hotspot where you'd like it.

 

Can you describe what your concern is, what problem you're trying to solve?

Share this post


Link to post
Share on other sites

Hello Buckeye

 

For me as a normal user i would suspect that the hotspot of the cursor is exactly where the vertical bar of the text cursor is. Everything else does not make any sense to me as thats the location you are clicking. Yet however if you take the 8 pixel offset you get from the icon info for the x-hotspot and go to that position in the cursors bitmap you land 2 pixels left of the vertical bar. That means on windows 7 if you want to get the effective location the user intended to click youd have to add 2 pixel to the value you get in WM_MOUSEMOVE or similar messages. If you dont do so youll drive the user nuts as he would have to click 2 pixels more left than he wants to click.

 

The use case i had problem implementing was:
The user clicks into the textbox and the caret of the textbox should move to the closest letter at the click position. Due to this 2 pixel offset to the left visually you had to click into the next letter to get the caret to the one you actually wanted.

 

So, yes, i say its not where i want it and i stay by my opinion: Its just plain wrong how it is right now.

 

Greetings

Plerion

Share this post


Link to post
Share on other sites


That means on windows 7 if you want to get the effective location the user intended to click youd have to add 2 pixel to the value you get in WM_MOUSEMOVE or similar messages.

Perhaps that's what applications must do. I haven't tried to write my own edit control as it's too easy to let Windows controls do that work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!