Skip to content

Commit 4cebe29

Browse files
committed
PayeeBox and CategoryBox: use offset and byte length
when interaction with a BTextView fix #121
1 parent 9799d8c commit 4cebe29

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/CategoryBox.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ CategoryBoxFilter::KeyFilter(const int32& key, const int32& mod)
6161
TextControl()->TextView()->Delete(start, end);
6262
BString string = "";
6363
GetCurrentMessage()->FindString("bytes", &string);
64+
int32 charLength = string.Length();
6465

6566
string.Prepend(TextControl()->Text());
6667

@@ -69,7 +70,7 @@ CategoryBoxFilter::KeyFilter(const int32& key, const int32& mod)
6970
autocomplete = string;
7071

7172
BMessage automsg(M_CATEGORY_AUTOCOMPLETE);
72-
automsg.AddInt32("start", strlen(TextControl()->Text()) + 1);
73+
automsg.AddInt32("start", strlen(TextControl()->Text()) + charLength);
7374
automsg.AddString("string", autocomplete.String());
7475
SendMessage(&automsg);
7576
}

src/CheckView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ CheckView::MessageReceived(BMessage* msg)
162162
msg->FindInt32("start", &start);
163163
msg->FindString("string", &string);
164164
fPayee->SetText(string.String());
165-
fPayee->TextView()->Select(start, string.CountChars());
165+
fPayee->TextView()->Select(start, string.Length());
166166
break;
167167
}
168168
case M_CATEGORY_AUTOCOMPLETE:
169169
{
170170
msg->FindInt32("start", &start);
171171
msg->FindString("string", &string);
172172
fCategory->SetText(string.String());
173-
fCategory->TextView()->Select(start, string.CountChars() + 2);
173+
fCategory->TextView()->Select(start, string.Length());
174174
break;
175175
}
176176

src/PayeeBox.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ PayeeBoxFilter::KeyFilter(const int32& key, const int32& mod)
6464
TextControl()->TextView()->Delete(start, end);
6565
BString string = "";
6666
GetCurrentMessage()->FindString("bytes", &string);
67+
int32 charLength = string.Length();
6768

6869
string.Prepend(TextControl()->Text());
6970

@@ -72,7 +73,7 @@ PayeeBoxFilter::KeyFilter(const int32& key, const int32& mod)
7273
autocomplete = string;
7374

7475
BMessage automsg(M_PAYEE_AUTOCOMPLETE);
75-
automsg.AddInt32("start", strlen(TextControl()->Text()) + 1);
76+
automsg.AddInt32("start", strlen(TextControl()->Text()) + charLength);
7677
automsg.AddString("string", autocomplete.String());
7778
SendMessage(&automsg);
7879
}

src/SplitView.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ SplitView::MessageReceived(BMessage* msg)
308308
msg->FindInt32("start", &start);
309309
msg->FindString("string", &string);
310310
fPayee->SetText(string.String());
311-
fPayee->TextView()->Select(start, string.CountChars());
311+
fPayee->TextView()->Select(start, string.Length());
312312
break;
313313
}
314314
case M_CATEGORY_AUTOCOMPLETE:
@@ -317,10 +317,10 @@ SplitView::MessageReceived(BMessage* msg)
317317
msg->FindString("string", &string);
318318
if (fSplitContainer->IsHidden()) {
319319
fCategory->SetText(string.String());
320-
fCategory->TextView()->Select(start, string.CountChars());
320+
fCategory->TextView()->Select(start, string.Length());
321321
} else {
322322
fSplitCategory->SetText(string.String());
323-
fSplitCategory->TextView()->Select(start, string.CountChars());
323+
fSplitCategory->TextView()->Select(start, string.Length());
324324
}
325325
break;
326326
}

0 commit comments

Comments
 (0)