Make sure when adding a new source that the list item coresponding to it is visible and selected (also deselect all previous selected items)
This commit is contained in:
parent
5962b8fe89
commit
40dd74e06b
@ -713,6 +713,16 @@ LRESULT CALLBACK OBS::ListboxHook(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||||||
}
|
}
|
||||||
|
|
||||||
UINT numSources = sources->NumElements();
|
UINT numSources = sources->NumElements();
|
||||||
|
|
||||||
|
// clear selection/focus for all items before adding the new item
|
||||||
|
UINT itemState;
|
||||||
|
for(int i = 0; i<numSources; i++)
|
||||||
|
{
|
||||||
|
itemState = ListView_GetItemState(hwnd, i, LVIS_SELECTED);
|
||||||
|
if(itemState & LVIS_SELECTED || itemState & LVIS_FOCUSED)
|
||||||
|
ListView_SetItemState(hwnd , i , 0, LVIS_SELECTED|LVIS_FOCUSED);
|
||||||
|
}
|
||||||
|
|
||||||
ListView_SetItemCount(hwnd, numSources);
|
ListView_SetItemCount(hwnd, numSources);
|
||||||
|
|
||||||
App->bChangingSources = true;
|
App->bChangingSources = true;
|
||||||
@ -720,7 +730,10 @@ LRESULT CALLBACK OBS::ListboxHook(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||||||
App->bChangingSources = false;
|
App->bChangingSources = false;
|
||||||
|
|
||||||
SetFocus(hwnd);
|
SetFocus(hwnd);
|
||||||
ListView_SetItemState(hwnd, numSources - 1, LVIS_SELECTED, LVIS_SELECTED);
|
|
||||||
|
// make sure the added item is visible and selected/focused
|
||||||
|
ListView_EnsureVisible(hwnd, numSources - 1, false);
|
||||||
|
ListView_SetItemState(hwnd, numSources - 1, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user