From a70e506a80d390997bda0ad4fb76b4271ea8e1f1 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sat, 16 Nov 2019 01:57:13 -0500 Subject: [PATCH] Locale prefs: Select items after drag and drop in the Preferred Languages ListView. Change-Id: I423263ba0c6753a278f70e479eb2b711ca1d7670 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1959 Reviewed-by: waddlesplash --- src/preferences/locale/LocaleWindow.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/preferences/locale/LocaleWindow.cpp b/src/preferences/locale/LocaleWindow.cpp index 0eff7167a2..71caedf54f 100644 --- a/src/preferences/locale/LocaleWindow.cpp +++ b/src/preferences/locale/LocaleWindow.cpp @@ -350,15 +350,18 @@ LocaleWindow::MessageReceived(BMessage* message) if (message->FindInt32("drop_index", &dropIndex) != B_OK) dropIndex = fPreferredListView->CountItems(); - int32 index = 0; - for (int32 i = 0; message->FindInt32("index", i, &index) == B_OK; - i++) { + int32 i = 0; + for (int32 index = 0; + message->FindInt32("index", i, &index) == B_OK; i++) { LanguageListItem* item = static_cast( fLanguageListView->ItemAt(index)); _InsertPreferredLanguage(item, dropIndex++); } + + fPreferredListView->Select(dropIndex - i, dropIndex - 1); break; } + case kMsgLanguageInvoked: { int32 index = 0; @@ -381,8 +384,8 @@ LocaleWindow::MessageReceived(BMessage* message) if (target == fPreferredListView) { // change ordering int32 dropIndex = message->FindInt32("drop_index"); - int32 index = 0; - for (int32 i = 0; + int32 i = 0; + for (int32 index = 0; message->FindInt32("index", i, &index) == B_OK; i++, dropIndex++) { if (dropIndex > index) { @@ -393,6 +396,7 @@ LocaleWindow::MessageReceived(BMessage* message) fPreferredListView->AddItem(item, dropIndex); } + fPreferredListView->Select(dropIndex - i, dropIndex - 1); _PreferredLanguagesChanged(); break; }