public void UpdateEditButtons()
{
if (_copyCommand == null)
return;
if (InvokeRequired)
{
Invoke(new Action(UpdateEditButtons));
return;
}
try
{
// BL-3658 GeckoFx-45 has a bug in the CanXSelection Properties, they always return 'true'
// Tom Hindle suggested a workaround that seems to work.
var isTextSelection = IsThereACurrentTextSelection();
_cutCommand.Enabled = _browser != null && isTextSelection;
_copyCommand.Enabled = _browser != null && isTextSelection;
//_cutCommand.Enabled = _browser != null && _browser.CanCutSelection;
//_copyCommand.Enabled = _browser != null && _browser.CanCopySelection;
_pasteCommand.Enabled = _browser != null && _browser.CanPaste;
if (_pasteCommand.Enabled)
{
//prevent pasting images (BL-93)
_pasteCommand.Enabled = PortableClipboard.ContainsText();
}
_undoCommand.Enabled = CanUndo;
}
catch (Exception)
{
_pasteCommand.Enabled = false;
Logger.WriteMinorEvent("UpdateEditButtons(): Swallowed exception.");
//REf jira.palaso.org/issues/browse/BL-197
//I saw this happen when Bloom was in the background, with just normal stuff on the clipboard.
//so it's probably just not ok to check if you're not front-most.
}
}