Page 1 of 1

Manage Keyboard actions inside Edit boxes

PostPosted: Sun Aug 29, 2021 10:04 am
by Buscet
Hi,

I would like to write my first plugin,
but how can I avoid,
while navigating/editing inside a textfield (using the left/rigth cursor buttons) in my plugin-form
that in the same time the "x-axis" is also jogging to the left/right(because of keyboard shortcut assignment).

I saw this behavior also in
- "PluginTest" plugin
- "the laser engraver" plugin (I added a screenshot)
- WebCam plugin

How can I manage that all "Key/Mouse activities" stay ONLY inside the plugin-form when it has the FOCUS.

Best regards
Buscet

Re: Manage Keyboard actions inside Edit boxes

PostPosted: Sun Aug 29, 2021 8:42 pm
by dezsoe
Use UC.Disablejog(true) when the form gets focus. Don't forget to reenable with UC.Disablejog(false).

Re: Manage Keyboard actions inside Edit boxes

PostPosted: Tue Aug 31, 2021 5:42 pm
by Buscet
Hi Dezsoe,
thank very much, for you fast answer.

Your solution works well for all Edit Boxes, Tab Controls ...
Code: Select all
private void textBox_Enter(object sender, EventArgs e)
        {
            // Console.Write("Form Entered");
            UC.Disablejog(true); // to avoid accidently Cursor-Jog in open Edit Fields
        }

private void textBox_Leave(object sender, EventArgs e)
        {
            // Console.Write("Leave Form");
            UC.Disablejog(false); // enable again Cursor-Jog
        }

private void PluginForm_FormClosing(object sender, FormClosingEventArgs e)
        {

            UC.Disablejog(false); // enable again Cursor-Jog when closing the form
         ...

Onother good Practice can also be to Set "dropdown Lists" and numeric "updown" inputs to read only:

Remark:
In my tests, it did not work for the PluginForm 'Enter' Event. :?:
I don't know why, maybe you have an idea what could be wrong.
But this is not important.

Kösz Dezsoe

Re: Manage Keyboard actions inside Edit boxes

PostPosted: Tue Aug 31, 2021 6:01 pm
by dezsoe
You can also use a timer to check if the form is active:

Code: Select all
            if (Form.ActiveForm == this)
            {
                if (!jogDisabled)
                    UC.Disablejog(true);
                jogDisabled = true;
            }
            else
            {
                if (jogDisabled)
                    UC.Disablejog(false);
                jogDisabled = false;
            }