Open videosmith opened 8 months ago
Positions are adjusted based on where the reading region is pointing to, prior to considering the actual position of the cursor.
If only the cursor position were used, and you went through a long script making changes, and then back to the start to start prompting, the moment the Normal font size was restored, the viewport's position would jump all the way back to near the bottom of the script to where the text cursor remained placed, and the user would have to scroll a long distance to where they were a moment ago.
The solution I came up with is that when sizes are toggled, the cursor position is set to the beginning of the line the reading region points to. Nevertheless, this repositioning intentionally doesn't happen when going from small to normal when the position of the text cursor is within the line the reading region is pointing to, which allows us to return to our previous line in the case of the button for toggling between font sizes being toggled multiple times one after the other.
In other words, this was a small compromise and a design choice made to prevent QPrompt from becoming frustrating to users. Having said that, there might be room for improvement here. It might be possible to compare against the area visible inside the viewport and not just the position of the reading region, then only use the reading region if the cursor is outside of the visible area...
I'll leave this open for now, to do experiments later.
Details copied from #245:
Bug Description When cycling between normal and small font sizes, unless beginning of paragraph coincides with the middle of the prompt window, cursor position moves. Also appears to occur when paragraph spacing is >000%
Steps to Reproduce
Expected behavior Cursor should always position where is was placed regardless of script position
Device information
Bug Description When changing from Normal to Small fonts or back, the current cursor location changes.
Steps to Reproduce
Expected behavior Cursor location should remain next to the same text.
Screenshots (optional)
![Screenshot from 2023-10-15 13-10-10](https://github.com/Cuperino/QPrompt/assets/88691671/d552a9ed-ee42-4d41-8e27-325fe9655e73)
Device information