mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-07 14:31:00 +00:00
Workaround for GridSplitter lockup
As noted in issue #52, the side panels can't be resized once the ListView gets focus. The root of the problem is a workaround for a selection problem that involves catching the Item Container Generator's Status Changed event, and setting an item's focus. It appears that changing the size of the ListView causes the StatusChanged event to fire, which cause the handler to grab the focus, which causes the splitters to stop moving after one step. This change adds a workaround that prevents the original workaround from doing anything while a splitter is in the process of being dragged. It doesn't solve all problems -- you can't move the splitters more than one step with the keyboard -- but it allows them to be dragged around with the mouse. There's got to be a better way to deal with this.
This commit is contained in:
parent
0c02b3ebe3
commit
2ddd3b400d
@ -461,10 +461,12 @@ limitations under the License.
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*" MinWidth="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<GridSplitter Name="leftSplitter" Width="4" Grid.Column="1" HorizontalAlignment="Left"/>
|
||||
<GridSplitter Name="rightSplitter" Width="4" Grid.Column="3" HorizontalAlignment="Center"/>
|
||||
|
||||
<GridSplitter Grid.Column="1" Width="4" HorizontalAlignment="Left"
|
||||
DragStarted="ColSplitter_OnDragStarted" DragCompleted="ColSplitter_OnDragCompleted"/>
|
||||
<GridSplitter Grid.Column="3" Width="4" HorizontalAlignment="Center"
|
||||
DragStarted="ColSplitter_OnDragStarted" DragCompleted="ColSplitter_OnDragCompleted"/>
|
||||
|
||||
<Grid Name="leftPanel" Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -832,8 +832,24 @@ namespace SourceGen.WpfGui {
|
||||
/// control rather than an item. The same fix seems to apply for this issue as well.
|
||||
///
|
||||
/// From http://cytivrat.blogspot.com/2011/05/selecting-first-item-in-wpf-listview.html
|
||||
///
|
||||
/// Unfortunately, grabbing focus like this causes problems with the GridSplitters. As
|
||||
/// soon as the splitter start to move, the ListView grabs focus and prevents them from
|
||||
/// moving more than a few pixels. The workaround is to do nothing while the
|
||||
/// splitters are being moved. This doesn't solve the problem completely, e.g. you
|
||||
/// can't move the splitters with the arrow keys by more than one step because the
|
||||
/// ListView gets a StatusChanged event and steals focus away, but at least the
|
||||
/// mouse works.
|
||||
///
|
||||
/// Ideally we'd do something smarter with the StatusChanged event, or maybe find some
|
||||
/// way to deal with the selection-jump problem that doesn't involve the StatusChanged
|
||||
/// event, but short of a custom replacement control I don't know what that would be.
|
||||
/// https://stackoverflow.com/q/58652064/294248
|
||||
/// </remarks>
|
||||
private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e) {
|
||||
if (mIsSplitterBeingDragged) {
|
||||
return;
|
||||
}
|
||||
if (codeListView.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) {
|
||||
int index = codeListView.SelectedIndex;
|
||||
|
||||
@ -848,6 +864,15 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
}
|
||||
|
||||
private bool mIsSplitterBeingDragged = false;
|
||||
private void ColSplitter_OnDragStarted(object sender, DragStartedEventArgs e) {
|
||||
mIsSplitterBeingDragged = true;
|
||||
}
|
||||
|
||||
private void ColSplitter_OnDragCompleted(object sender, DragCompletedEventArgs e) {
|
||||
mIsSplitterBeingDragged = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the line that's currently at the top of the control.
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user