Skip to content

Commit

Permalink
Fixed crash when pressing tab from editing existing row.
Browse files Browse the repository at this point in the history
Tab and right should now work identically when not editing.
When editing, tab should act like right, except going via the play button column.
  • Loading branch information
CaffeineAU committed Aug 23, 2016
1 parent 3c4036a commit faf86c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions Translator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Setter Property="Content" Value="Play" />
<Setter Property="IsEnabled" Value="False" />
<Setter Property="Visibility" Value="Visible" />
<Setter Property="Focusable" Value="False"/>
<Style.Triggers>
<DataTrigger Binding="{Binding DownloadComplete}" Value="False">
<Setter Property="Content" Value="Preview" />
Expand Down
24 changes: 16 additions & 8 deletions Translator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,15 @@ private void WordsListView_PreviewKeyDown(object sender, KeyEventArgs e)
if (cell.Column.Header.ToString() == "Play" || cell.Column.Header.ToString() == "Phrase to Speak")
{

//}
nextRowCell = cell.PredictFocus(FocusNavigationDirection.Left);
//}
nextRowCell = cell.PredictFocus(FocusNavigationDirection.Left);

//if (nextRowCell == null || (!(nextRowCell is Button)&&(nextRowCell as DataGridCell).Column.Header.ToString() == "Play"))
//{
// nextRowCell = cell.PredictFocus(FocusNavigationDirection.Left);
while (!(nextRowCell is DataGridCell))
{
nextRowCell = VisualTreeHelper.GetParent(nextRowCell);

}
// nextRowCell = cell.PredictFocus(FocusNavigationDirection.Left);

while ((nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left) != null)
{
Expand All @@ -838,6 +841,11 @@ private void WordsListView_PreviewKeyDown(object sender, KeyEventArgs e)
nextRow = VisualTreeHelper.GetParent(nextRowCell);
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left);
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left);
if (cell.Column.Header.ToString() == "Play")
{
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left);

}
while ((nextRow != null) && !(nextRow is DataGridRow) && !(nextRow is System.Windows.Controls.Primitives.DataGridColumnHeader))
{
nextRow = VisualTreeHelper.GetParent(nextRow);
Expand All @@ -846,10 +854,10 @@ private void WordsListView_PreviewKeyDown(object sender, KeyEventArgs e)
SelectedRowCount = WordsListView.SelectedItems.Count;
if (Properties.Settings.Default.CopyFolderWhenSelectingEmptyRow && String.IsNullOrEmpty(((nextRow as DataGridRow).Item as PhraseItem).Folder))
{
if (cell.Column.Header.ToString() != "Play")
{
//if (cell.Column.Header.ToString() != "Play")
//{
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Right);
}
//}
int rowselected = PhraseItems.IndexOf(((nextRow as DataGridRow).Item as PhraseItem) as PhraseItem);
while (String.IsNullOrEmpty(PhraseItems[rowselected].Folder) && rowselected >= 0) { rowselected--; } // traverse upwards
if (rowselected >= 0)
Expand Down
4 changes: 2 additions & 2 deletions Translator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.2")]
[assembly: AssemblyFileVersion("2.2.0.2")]
[assembly: AssemblyVersion("2.2.0.3")]
[assembly: AssemblyFileVersion("2.2.0.3")]

0 comments on commit faf86c5

Please sign in to comment.