Skip to content

Commit

Permalink
Make channel selection input more responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Jul 15, 2023
1 parent f553a81 commit 0162dbf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
2 changes: 1 addition & 1 deletion Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<TextBlock FontSize="14" Text="Channel" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose which deployment channel Roblox should be downloaded from." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
<ComboBox Grid.Column="1" Margin="8,0,8,0" Padding="10,5,10,5" Width="200" IsEditable="True" ItemsSource="{Binding Channels, Mode=OneWay}" Text="{Binding SelectedChannel, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" KeyUp="ComboBox_KeyEnterUpdate" />
<ComboBox Grid.Column="1" Margin="8,0,8,0" Padding="10,5,10,5" Width="200" IsEditable="True" ItemsSource="{Binding Channels, Mode=OneWay}" Text="{Binding SelectedChannel, Mode=TwoWay, Delay=250}" />
</Grid>
</ui:CardExpander.Header>
<StackPanel>
Expand Down
16 changes: 0 additions & 16 deletions Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,5 @@ public BehaviourPage()
DataContext = new BehaviourViewModel();
InitializeComponent();
}

// https://stackoverflow.com/a/13289118/11852173
// yes this doesnt fully conform to xaml but whatever
private void ComboBox_KeyEnterUpdate(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
ComboBox box = (ComboBox)sender;
DependencyProperty prop = ComboBox.TextProperty;

BindingExpression binding = BindingOperations.GetBindingExpression(box, prop);

if (binding is not null)
binding.UpdateSource();
}
}
}
}

0 comments on commit 0162dbf

Please sign in to comment.