Change the Function Keys on a Handheld Screen

I would like to reuse a particular Handheld screen as it does 90% of what I need. I am removing certain functionality, but leaving the items I need (HHPackout).
I would like to remove the “Ship F2” button functionality. I obviously can hide the button, but what if I want to change what F2 does? How can I change what it does and possibly assign new Function keys?
image

1 Like

Perhaps you can use shared properties?

Take a look at this customisation I did for duplicating lines.
https://www.epiusers.help/t/copy-line-paste-insert-hotkeys-on-sales-order/56368/3 search for F12

The other thing you could look at is debugging with the dnspy in the Epicor VS code extension or using debug in Visual Studio option to understand how it works.

Looking into things deeper the OnFormLoad method of the form looks like

       protected override void OnFormLoad()
        {
            base.OnFormLoad();
            this.LoadButtonCaptions();
            base.CancelButton = this.mainPanel1.detailPanel1.cmdClose;
            base.RegisterHotKey(Shortcut.F2);
            base.RegisterHotKey(Shortcut.F3);
            base.RegisterHotKey(Shortcut.F4);
            base.RegisterHotKey(Shortcut.F5);
            base.RegisterHotKey(Shortcut.F6);
            base.RegisterHotKey(Shortcut.F7);
            base.RegisterHotKey(Shortcut.F8);

F2 is hardcoded to the OnClickHotKey method so repurposing F2 I think you might be out of luck.

Food for thought, you can try to hijack the key.

Turn on KeyPreview on the form.
Handle key press
if (YourDesiredKeys) DoSomething; Handled = true;

1 Like

@Chris_Conn was correct. Here is my final code:

	private void HHMtlQScanIDForm_Load(object sender, EventArgs args)
	{
		HHMtlQScanIDForm.KeyPreview = true;
	}

	private void Form_KeyDown(object sender, KeyEventArgs e)
	{
		if (e.KeyCode == Keys.F2)
		{
			e.Handled = false;
			MessageBox.Show("F2 Pressed");
		}
	}
2 Likes

I use this function to recreate the Epicor function. You can register a hotkey to do all sorts of fun stuff since you are programming the toolbutton action. Extra creative points for not even showing a button tool but using the hot keys to execute field focus and tab sheet changes :slight_smile:

private void RegisterHotKeys()
{
     RegisterHotKey(Shortcut.F1, "EpiAddNewnewOrder");
     RegisterHotKey(Shortcut.F2, "EpiAddNewnewLine");
     RegisterHotKey(Shortcut.F4, "EpiAddNewnewLineMiscCharge");
     RegisterHotKey(Shortcut.CtrlS, "SaveTool");        
     RegisterHotKey(Shortcut.CtrlP, "PrintTool");
     RegisterHotKey(Shortcut.CtrlShiftS, "PrimarySearchTool");
}

private void RegisterHotKey(Shortcut hk, String toolKey) {
     oTrans.EpiBaseForm.GetType().GetMethod("RegisterHotKey",BindingFlags.NonPublic | BindingFlags.Instance).Invoke(oTrans.EpiBaseForm, new object[]{hk});
     baseToolbarsManager.Tools[toolKey].SharedProps.Shortcut = hk;
}
3 Likes