Opened 10 years ago

Closed 10 years ago

#3458 closed enhancement (fixed)

BTextView's Caret drawing

Reported by: Blub Owned by: zooey
Priority: normal Milestone: R1
Component: Kits/Interface Kit Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All


I'm using a BTextView in a small app I write to get to know the BeAPI. I have two suggestions, although the first one could be seen more like a bug-fix instead of an enhancement:

1) Invalidating the caret in GoToLine()
I added keys to move through the text by multiple lines at once and noticed the following (bad) behaviour:

When the caret is visible GoToLine() does not invalidate the old caret BRect, which causes the caret to stay visible:

The first line there has 3 rendered carets. And since the _DrawCaret() function only does InvertRect() moving to and away from those carets won't remove them, so I manually have to Invalidate(). But Invalidate()ing when ScrollToSelection() didn't actually scroll seems unclean since it then redraws the whole textview. Now the fastest solution would be to have GoToLine() invalidate the old caret position.

Although, when your application uses GoToLine() multiple times to do editing at special positions - most of which can be done without GoToLine() if I'm not mistaken, maybe even all of them - you'd think that it would "undraw" the caret too often, but really _HideCaret does check if the caret is already hidden, since as mentioned above, it only does InvertRect().

2) Showing the caret when moving
I have noticed that when moving the caret it usually disappears, especially Select() calls _HideCaret() but doesn't call _ShowCaret(), which IMHO it should, if start == end (in other words, if you just place the insertion point)

I also have a .diff for both patches applied, however, please read on:

3) The clash
Above I have started an argument that using GoToLine() repeatedly with the first patch shouldn't cause any trouble since _HideCaret() checks if the caret is already hidden. However, when applying both patches, GoToLine() hides and also shows the caret, which, when shooting the GoToLine() calls outta a machine gun could lead to slow rendering... Personally I don't think GoToLine() is used too often to apply those patches.

Combined .diff:

Change History (2)

comment:1 Changed 10 years ago by zooey

Owner: changed from axeld to zooey
Status: newassigned

comment:2 Changed 10 years ago by zooey

Resolution: fixed
Status: assignedclosed

Thanks, Blub - both patches were applied in hrev29983.

Note: See TracTickets for help on using tickets.