Skip to content

Fix edit box cursor click location - #10300

Open
AdamZ-8113 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
AdamZ-8113:fix-editbox-cursor-click-location
Open

Fix edit box cursor click location#10300
AdamZ-8113 wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
AdamZ-8113:fix-editbox-cursor-click-location

Conversation

@AdamZ-8113

Copy link
Copy Markdown
Contributor

Fixes #

Description of the problem being solved:

In simple terms, clicking within the item editor box is inaccurate when scaling isn't set to 100%.

At display scaling other than 100%, EditControl:Draw positioned each focused line using PoB’s textHeight spacing, while DrawStringCursorIndex calculated clicks using SimpleGraphic’s internally rounded multiline spacing. This difference accumlates over time, making clicks increasingly inaccurate farther down the editor. This behavior was confirmed by Zao (the issue is "further south" not "further east", but more or less the same).

The fix makes drawing and clicking use the same line spacing. PoB determines which line was clicked using textHeight, then calls DrawStringCursorIndex only to find the horizontal character position within that single line. Unfocused multiline text is also drawn one line at a time, so its position no longer changes when the editor gains focus.

Steps taken to verify a working solution:

  • Find or create an item in PoB with lots of modifiers/lines of text, like this:
Conquest Lamellar
Armour: 1925
ArmourBasePercentile: 1
Evasion: 1925
EvasionBasePercentile: 1
Searing Exarch Item
Eater of Worlds Item
Crafted: true
Prefix: {range:1}LocalIncreasedArmourAndEvasion4
Prefix: {range:1}LocalIncreasedArmourAndEvasionAndStunRecovery3
Prefix: {range:0.5}IncreasedLife6
Suffix: {range:1}ReducedLocalAttributeRequirements1
Suffix: {range:0.5}MercenaryModLightningSkillManaCostWhileShocked
Suffix: {range:0.5}MercenaryModConsecratedChaosRes
Quality: 20
Sockets: G-G-G-G-G-G
LevelReq: 84
Implicits: 2
{tags:physical_damage,damage,physical}{exarch}{range:0.5}(15-17)% increased Global Physical Damage
{eater}Prevent +45% of Reflected Damage
{suffix}18% reduced Attribute Requirements
{tags:defences,armour,evasion}{prefix}93% increased Armour and Evasion
{tags:resource,life}{prefix}+92 to maximum Life
{tags:defences,armour,evasion}{prefix}11% increased Stun and Block Recovery
{tags:resource,mana,elemental,lightning}{suffix}40% less Mana cost of Lightning Skills while Shocked
{tags:chaos}{suffix}Consecrated Ground you create grants +2% maximum Chaos Resistance to you and Allies
  • Edit the item
  • On the unfixed versions, when scaling is >100%, click on any lines near the bottom, observe the text cursor being inserted above the location you're clicking
  • With the PR applied, clicking result in accurate text cursor placement

Link to a build that showcases this PR:

Before screenshot:

After screenshot:

@vaisest

vaisest commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants