Manage Keyboard actions inside Edit boxes

This is where you talk about Plugins. How they are made and how they work, show examples.

Manage Keyboard actions inside Edit boxes

Postby Buscet » Sun Aug 29, 2021 10:04 am

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
Attachments
Screenshot.jpg
laser engraver
Buscet
 
Posts: 2
Joined: Mon Aug 09, 2021 6:27 pm
Location: Universe -> World -> Europe -> France

Re: Manage Keyboard actions inside Edit boxes

Postby dezsoe » Sun Aug 29, 2021 8:42 pm

Use UC.Disablejog(true) when the form gets focus. Don't forget to reenable with UC.Disablejog(false).
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Manage Keyboard actions inside Edit boxes

Postby Buscet » Tue Aug 31, 2021 5:42 pm

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
Buscet
 
Posts: 2
Joined: Mon Aug 09, 2021 6:27 pm
Location: Universe -> World -> Europe -> France

Re: Manage Keyboard actions inside Edit boxes

Postby dezsoe » Tue Aug 31, 2021 6:01 pm

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;
            }
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Plugins

Who is online

Users browsing this forum: No registered users and 6 guests