|
|
@ -6,6 +6,7 @@ |
|
|
|
|
|
|
|
|
namespace Perspex.Controls.Primitives |
|
|
namespace Perspex.Controls.Primitives |
|
|
{ |
|
|
{ |
|
|
|
|
|
using System; |
|
|
using Perspex.Media; |
|
|
using Perspex.Media; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -27,6 +28,23 @@ namespace Perspex.Controls.Primitives |
|
|
AffectsRender(ShowAccessKeyProperty); |
|
|
AffectsRender(ShowAccessKeyProperty); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="AccessText"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public AccessText() |
|
|
|
|
|
{ |
|
|
|
|
|
this.GetObservable(TextProperty).Subscribe(this.TextChanged); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the access key.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public char AccessKey |
|
|
|
|
|
{ |
|
|
|
|
|
get; |
|
|
|
|
|
private set; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets or sets a value indicating whether the access key should be underlined.
|
|
|
/// Gets or sets a value indicating whether the access key should be underlined.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
@ -104,5 +122,25 @@ namespace Perspex.Controls.Primitives |
|
|
return text.Substring(0, position) + text.Substring(position + 1); |
|
|
return text.Substring(0, position) + text.Substring(position + 1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the <see cref="Text"/> property changes.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="text">The new text.</param>
|
|
|
|
|
|
private void TextChanged(string text) |
|
|
|
|
|
{ |
|
|
|
|
|
if (text != null) |
|
|
|
|
|
{ |
|
|
|
|
|
int underscore = text.IndexOf('_'); |
|
|
|
|
|
|
|
|
|
|
|
if (underscore != -1 && underscore < text.Length - 1) |
|
|
|
|
|
{ |
|
|
|
|
|
this.AccessKey = text[underscore + 1]; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.AccessKey = (char)0; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|