Question on activating a plugin with a button

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

Question on activating a plugin with a button

Postby Vmax549 » Sun Nov 04, 2018 6:32 pm

I am back working with plugins and have a question about starting a plugin with a button. In teh past I simply called teh plugin but that does not always work.

I need to be able to call teh plugin into play with a button call. I am using this code and it works to a point. It fires up teh plugin BUT then shuts back down. SO something I am doing wrong.

//Called when the user presses a button on the UCCNC GUI or if a Callbutton function is executed.
//The int buttonnumber parameter is the ID of the caller button.
// The bool onscreen parameter is true if the button was pressed on the GUI and is false if the Callbutton function was called.

public void Buttonpress_event(int buttonnumber, bool onscreen)
{
if (onscreen)
{
if (buttonnumber == 21000)
{
// myform = new PluginForm(this);
myform.Show();
myform.BringToFront();
}
}
}


OR maybe I am calling it from teh wrong spot ??

Anybody have an idea to make it work ??

(;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Question on activating a plugin with a button

Postby dezsoe » Sun Nov 04, 2018 9:55 pm

It should work. There must be something else in myform that inactivates your plugin (or just the form).

Some comments on showing plugins this way. Don't use the 2xxxx buttoncodes, because the main program will search for a macro M2xxxx. If you want to activate your plugin with exec.Callbutton() then don't check for the onscreen parameter.

Code: Select all
public void Buttonpress_event(int buttonnumber, bool onscreen)
{
  if (buttonnumber == 10000)
  {
    // myform = new PluginForm(this);
    myform.Show();
    myform.BringToFront();
  }
}
dezsoe
 
Posts: 573
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Question on activating a plugin with a button

Postby Vmax549 » Sun Nov 04, 2018 10:02 pm

Thanks Dezsoe I will look for something that is closing teh Form.

YES using teh 20xxx number will call teh macro. I also tried doing a hotkey and it would not except a number over 21000. SO i guess I have to go under 20000 for a hotkey number ?

(;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Question on activating a plugin with a button

Postby dezsoe » Sun Nov 04, 2018 10:22 pm

Yes. I don't know the upper limit, but the hotkey (and all trigger) settings are limited to 0..21000. Only the input fields, so it is only an error in the screenset file from the past.
dezsoe
 
Posts: 573
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Question on activating a plugin with a button

Postby Vmax549 » Mon Nov 05, 2018 1:36 am

oK I have looked for something that is shutting teh plugin down but do not see it. I can trigger teh SHOW in teh plugin config window and it opens fine and I can CALL teh plugin and it works ok.

I used teh Plugin test as a model SO I will have to try an example of teh stock plugintest and see if it does it there as well.

(;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Question on activating a plugin with a button

Postby Vmax549 » Mon Nov 05, 2018 1:58 am

I am not sure I am applying this in teh right place. I added it to where all teh other event functions are like click_event,Button_Event,etc.

It seems it may need to be somewhere else to start teh plugin.

(;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Question on activating a plugin with a button

Postby Vmax549 » Sun Nov 11, 2018 8:27 pm

HI Deszoe, I am still not able to activate a plugin via a hotkey like Dan does it. The best I can do is it will load up for about 3 secs then close down . So I am not doing something correct.

Could you modify teh PluginTest sample in UCCNC and then upload teh source to here as an example as to how it is done ?? I am sure I am not the only one that wants to use it :)

Thanks (;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Question on activating a plugin with a button

Postby dezsoe » Sun Nov 11, 2018 9:11 pm

Hi Terry,

I had to make it first, because I don't program in C# and I don't use this technique. :) (I program in VB and I have a "central" plugin which handles all buttons, LEDs, etc. and I have to change only the profile to activate my plugins. Nothing is fixed, all buttonnumbers are changeable in the profile.)

This is the Buttonpress_event of the sample code modified to start on button 5432:

Code: Select all
        public void Buttonpress_event(int buttonnumber, bool onscreen)
        {
            if (buttonnumber == 5432)
            {
                if (myform == null)
                    myform = new PluginForm(this);
                if (myform.IsDisposed)
                    myform = new PluginForm(this);
                if (!myform.Visible)
                    myform.ShowDialog();
                else
                    myform.BringToFront();
            }
        }
dezsoe
 
Posts: 573
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Question on activating a plugin with a button

Postby Vmax549 » Sun Nov 11, 2018 10:07 pm

Thanks Dezsoe, That fixed it. I was close but would never have figured that one out on my own.

(;-) TP
Vmax549
 
Posts: 1380
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Question on activating a plugin with a button

Postby Dan911 » Sun Nov 11, 2018 10:51 pm

Terry, you or anyone who wants to write plugins have to put a little more effort in to learn C# and google, I posted this on Zone over a year ago.
Why I didn't reply here is it was a lot more than not putting something in the right place.

cnczone.JPG
Dan911
 
Posts: 470
Joined: Mon Oct 31, 2016 1:22 am
Location: USA


Return to Plugins

Who is online

Users browsing this forum: No registered users and 5 guests