improve keyboard accessibility
This commit is contained in:
parent
9515d658fb
commit
5843f307aa
@ -97,7 +97,7 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
cbo.Model = tm;
|
||||
// cbo.Dock = DockStyle.Fill;
|
||||
|
||||
this.Controls.Add(cbo, new GridLayout.Constraints(iRow, 1, 1, 1, ExpandMode.Horizontal));
|
||||
this.Controls.Add(cbo, new GridLayout.Constraints(iRow, 1, 1, 2, ExpandMode.Horizontal));
|
||||
|
||||
CustomOptionControls.Add(eo.PropertyName, cbo);
|
||||
}
|
||||
@ -124,7 +124,7 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
}
|
||||
// txt.Value = option.DefaultValue;
|
||||
|
||||
this.Controls.Add(txt, new GridLayout.Constraints(iRow, 1, 1, 1, ExpandMode.Horizontal));
|
||||
this.Controls.Add(txt, new GridLayout.Constraints(iRow, 1, 1, 2, ExpandMode.Horizontal));
|
||||
|
||||
CustomOptionControls.Add(eo.PropertyName, txt);
|
||||
}
|
||||
@ -136,7 +136,7 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
txt.Text = option.DefaultValue;
|
||||
if (option.MaximumLength.HasValue) txt.MaxLength = option.MaximumLength.Value;
|
||||
|
||||
this.Controls.Add(txt, new GridLayout.Constraints(iRow, 1, 1, 1, ExpandMode.Horizontal));
|
||||
this.Controls.Add(txt, new GridLayout.Constraints(iRow, 1, 1, 2, ExpandMode.Horizontal));
|
||||
|
||||
CustomOptionControls.Add(eo.PropertyName, txt);
|
||||
}
|
||||
@ -148,18 +148,25 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
chk.Checked = option.DefaultValue;
|
||||
chk.Text = option.Title;
|
||||
|
||||
this.Controls.Add(chk, new GridLayout.Constraints(iRow, 0, 1, 2, ExpandMode.Horizontal));
|
||||
this.Controls.Add(chk, new GridLayout.Constraints(iRow, 0, 1, 3, ExpandMode.Horizontal));
|
||||
CustomOptionControls.Add(eo.PropertyName, chk);
|
||||
}
|
||||
else if (eo is CustomOptionFile)
|
||||
{
|
||||
CustomOptionFile option = (eo as CustomOptionFile);
|
||||
|
||||
TextBox cmd = new TextBox();
|
||||
// AwesomeControls.FileTextBox.FileTextBoxControl cmd = new AwesomeControls.FileTextBox.FileTextBoxControl();
|
||||
Button cmd = new Button();
|
||||
cmd.Text = "_Browse...";
|
||||
cmd.Click += cmdFileBrowse_Click;
|
||||
// cmd.Dock = DockStyle.Fill;
|
||||
cmd.SetExtraData<CustomOption>("eo", eo);
|
||||
|
||||
TextBox txt = new TextBox();
|
||||
cmd.SetExtraData<TextBox>("txt", txt);
|
||||
|
||||
// AwesomeControls.FileTextBox.FileTextBoxControl cmd = new AwesomeControls.FileTextBox.FileTextBoxControl();
|
||||
txt.Click += cmdFileBrowse_Click;
|
||||
// cmd.Dock = DockStyle.Fill;
|
||||
txt.SetExtraData<CustomOption>("eo", eo);
|
||||
switch (option.DialogMode)
|
||||
{
|
||||
case CustomOptionFileDialogMode.Open:
|
||||
@ -174,9 +181,10 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
this.Controls.Add(cmd, new GridLayout.Constraints(iRow, 1, 1, 1, ExpandMode.Horizontal));
|
||||
this.Controls.Add(txt, new GridLayout.Constraints(iRow, 1, 1, 1, ExpandMode.Horizontal));
|
||||
this.Controls.Add(cmd, new GridLayout.Constraints(iRow, 2, 1, 1, ExpandMode.None));
|
||||
|
||||
CustomOptionControls.Add(eo.PropertyName, cmd);
|
||||
CustomOptionControls.Add(eo.PropertyName, txt);
|
||||
}
|
||||
|
||||
// tbl.ColumnCount = 2;
|
||||
@ -220,7 +228,14 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
fd.Text = "Select File to Open";
|
||||
if (fd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
(cmd as TextBox).Text = fd.SelectedFileNames[0]; // SelectedFileName = ofd.FileName;
|
||||
if (cmd is TextBox)
|
||||
{
|
||||
(cmd as TextBox).Text = fd.SelectedFileNames[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.GetExtraData<TextBox>("txt").Text = fd.SelectedFileNames[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (eo.DialogMode == CustomOptionFileDialogMode.Save)
|
||||
@ -229,7 +244,14 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
fd.Text = "Select File to Save";
|
||||
if (fd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
(cmd as TextBox).Text = fd.SelectedFileNames[0]; // SelectedFileName = sfd.FileName;
|
||||
if (cmd is TextBox)
|
||||
{
|
||||
(cmd as TextBox).Text = fd.SelectedFileNames[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.GetExtraData<TextBox>("txt").Text = fd.SelectedFileNames[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
|
||||
this.txtSearch = new TextBox();
|
||||
this.txtSearch.Changed += txtSearch_Changed;
|
||||
this.txtSearch.KeyDown += txtSearch_KeyDown;
|
||||
this.ctSearchAndShowAll.Controls.Add(this.txtSearch, new BoxLayout.Constraints(true, true));
|
||||
|
||||
this.chkShowAll = new CheckBox();
|
||||
|
||||
@ -94,7 +94,8 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
|
||||
if (tm.Rows.Count == 1)
|
||||
{
|
||||
// lv.Items[0].Selected = true;
|
||||
lv.SelectedRows.Clear();
|
||||
lv.SelectedRows.Add(tm.Rows[0]);
|
||||
}
|
||||
// lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
||||
}
|
||||
@ -128,7 +129,7 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
|
||||
private void txtSearch_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == KeyboardKey.Enter)
|
||||
if (e.Key == KeyboardKey.Enter)
|
||||
{
|
||||
if (lv.SelectedRows.Count != 1) return;
|
||||
|
||||
@ -137,7 +138,7 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
|
||||
Close();
|
||||
}
|
||||
else if (e.KeyData == KeyboardKey.Escape)
|
||||
else if (e.Key == KeyboardKey.Escape)
|
||||
{
|
||||
// already handled by GTK? but what about other platforms
|
||||
// Close();
|
||||
|
||||
@ -211,6 +211,45 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmObjectModel.Rows.Count == 1)
|
||||
{
|
||||
TreeModelRow row = ExpandSingleChildRows(tmObjectModel.Rows[0]);
|
||||
if (row != null)
|
||||
{
|
||||
tvObjectModel.SelectedRows.Clear();
|
||||
tvObjectModel.SelectedRows.Add(row);
|
||||
tvObjectModel_SelectionChanged(null, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
if (tvTemplate.SelectedRows.Count == 1)
|
||||
{
|
||||
Buttons[0].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[0].Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursively detects <see cref="TreeModelRow" /> with a single child row and expands it. If the <see cref="TreeModelRow" /> has zero child rows, returns that <see cref="TreeModelRow" />. Otherwise, if no such row is found, returns null.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="TreeModelRow" /> which has zero child rows, or null if no such <see cref="TreeModelRow" /> exists.</returns>
|
||||
/// <param name="row">Row.</param>
|
||||
private TreeModelRow ExpandSingleChildRows(TreeModelRow row)
|
||||
{
|
||||
if (row.Rows.Count == 1)
|
||||
{
|
||||
row.Expanded = true;
|
||||
return ExpandSingleChildRows(row.Rows[0]);
|
||||
}
|
||||
else if (row.Rows.Count == 0)
|
||||
{
|
||||
return row;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void InitializeProjectTemplateTreeView()
|
||||
@ -294,19 +333,6 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
tmTemplate.Rows.Add(lvi);
|
||||
}
|
||||
}
|
||||
|
||||
if (tmTemplate.Rows.Count > 0)
|
||||
{
|
||||
tvTemplate.SelectedRows.Clear();
|
||||
tvTemplate.Select(tmTemplate.Rows[0]);
|
||||
|
||||
tvTemplate_SelectionChanged(null, EventArgs.Empty);
|
||||
Buttons[0].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[0].Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void tvTemplate_SelectionChanged(object sender, EventArgs e)
|
||||
@ -499,19 +525,6 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
if (tmTemplate.Rows.Count > 0)
|
||||
{
|
||||
tvTemplate.SelectedRows.Clear();
|
||||
tvTemplate.Select(tmTemplate.Rows[0]);
|
||||
|
||||
tvTemplate_SelectionChanged(null, EventArgs.Empty);
|
||||
Buttons[0].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[0].Enabled = false;
|
||||
}
|
||||
|
||||
InitializeObjectModelTreeView();
|
||||
}
|
||||
|
||||
@ -694,6 +707,10 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
private void tvObjectModel_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (tvObjectModel.SelectedRows.Count < 1) return;
|
||||
|
||||
tmTemplate.Rows.Clear();
|
||||
tvTemplate.SelectedRows.Clear();
|
||||
|
||||
if (Mode == NewDialogMode.File)
|
||||
{
|
||||
RefreshDocumentTemplates(tvObjectModel.SelectedRows[0]);
|
||||
@ -702,6 +719,11 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
{
|
||||
RefreshProjectTemplates(tvObjectModel.SelectedRows[0]);
|
||||
}
|
||||
|
||||
if (tmTemplate.Rows.Count == 1)
|
||||
{
|
||||
tvTemplate.SelectedRows.Add(tmTemplate.Rows[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user