Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Src/XCore/xWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,11 @@ protected override void WndProc(ref Message m)
base.WndProc(ref m);
}

public void HandleKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
}

protected override void OnKeyDown(KeyEventArgs e)
{
if (!e.Handled && e.KeyCode == Keys.Tab && (e.Modifiers & Keys.Control) == Keys.Control)
Expand Down
36 changes: 28 additions & 8 deletions Src/xWorks/FwXWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,15 @@ public bool OnEditCut(object arg)
{
CheckDisposed();

if (m_viewHelper.ActiveView != null)
ActiveViewHelper viewHelper = m_viewHelper;
if (arg is ActiveViewHelper helper)
{
viewHelper = helper;
}
if (viewHelper.ActiveView != null)
{
using (new DataUpdateMonitor(this, "EditCut"))
return m_viewHelper.ActiveView.EditingHelper.CutSelection();
return viewHelper.ActiveView.EditingHelper.CutSelection();
}
return false;
}
Expand All @@ -641,8 +646,13 @@ public bool OnEditCopy(object arg)
{
CheckDisposed();

if (m_viewHelper.ActiveView != null)
return m_viewHelper.ActiveView.EditingHelper.CopySelection();
ActiveViewHelper viewHelper = m_viewHelper;
if (arg is ActiveViewHelper helper)
{
viewHelper = helper;
}
if (viewHelper.ActiveView != null)
return viewHelper.ActiveView.EditingHelper.CopySelection();
return false;
}

Expand All @@ -657,15 +667,20 @@ public bool OnEditPaste(object arg)
{
CheckDisposed();

if (m_viewHelper.ActiveView != null)
ActiveViewHelper viewHelper = m_viewHelper;
if (arg is ActiveViewHelper helper)
{
viewHelper = helper;
}
if (viewHelper.ActiveView != null)
{
string stUndo, stRedo;
ResourceHelper.MakeUndoRedoLabels("kstidEditPaste", out stUndo, out stRedo);
using (UndoableUnitOfWorkHelper undoHelper = new UndoableUnitOfWorkHelper(
Cache.ServiceLocator.GetInstance<IActionHandler>(), stUndo, stRedo))
using (new DataUpdateMonitor(this, "EditPaste"))
{
if (m_viewHelper.ActiveView.EditingHelper.PasteClipboard(Cache))
if (viewHelper.ActiveView.EditingHelper.PasteClipboard(Cache))
undoHelper.RollBack = false;
}
return true;
Expand Down Expand Up @@ -825,12 +840,17 @@ public bool OnEditSelectAll(object arg)
{
CheckDisposed();

if (m_viewHelper.ActiveView != null)
ActiveViewHelper viewHelper = m_viewHelper;
if (arg is ActiveViewHelper helper)
{
viewHelper = helper;
}
if (viewHelper.ActiveView != null)
{
try
{
EnableBulkLoadingDisableIdleProcessing(true);
m_viewHelper.ActiveView.EditingHelper.SelectAll();
viewHelper.ActiveView.EditingHelper.SelectAll();
}
finally
{
Expand Down
32 changes: 32 additions & 0 deletions Src/xWorks/PopupToolWindow.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using SIL.FieldWorks.Common.RootSites;
using SIL.LCModel;
using SIL.Utils;
using System;
Expand All @@ -18,6 +19,7 @@ public Control MainControl

private PropertyTable m_propertyTable;
private RecordClerk m_recordClerk;
protected ActiveViewHelper m_viewHelper;

public PopupToolWindow()
{
Expand All @@ -40,6 +42,8 @@ private void InitializeComponent()
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.Text = "Popup Tool Window";
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(PopupToolWindow_KeyDown);
this.Deactivate += new System.EventHandler(PopupToolWindow_Deactivate);
this.Activated += new System.EventHandler(PopupToolWindow_Activated);
this.ResumeLayout(false);
Expand All @@ -64,6 +68,32 @@ private void PopupToolWindow_Activated(object sender, EventArgs e)
}
}

private void PopupToolWindow_KeyDown(object sender, KeyEventArgs e)
{
FwXWindow fwXWindow = Owner as FwXWindow;
if (e.KeyCode == Keys.A && e.Control)
{
fwXWindow?.OnEditSelectAll(m_viewHelper);
}
if (e.KeyCode == Keys.C && e.Control)
{
fwXWindow?.OnEditCopy(m_viewHelper);
}
else if (e.KeyCode == Keys.V && e.Control)
{
fwXWindow?.OnEditPaste(m_viewHelper);
}
else if (e.KeyCode == Keys.X && e.Control)
{
fwXWindow?.OnEditCut(m_viewHelper);
}
else
{
// e.g. Control-Z.
fwXWindow?.HandleKeyDown(e);
}
}

private IxCoreColleague MainContentControlAsIxCoreColleague
{
get { return m_mainContentControl as IxCoreColleague; }
Expand Down Expand Up @@ -116,6 +146,8 @@ public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode toolNod
{
this.Text = toolNode.Attributes["label"].Value;
}
m_viewHelper = new ActiveViewHelper(this);

this.Show();
this.BringToFront();
this.Activate();
Expand Down
Loading