Page 1 of 1
Get strange issue with toggle button.
Posted:
Tue May 15, 2018 11:13 am
by kig23
I need to make some controls befor i start the spindel. So i change the M3toggle button for 114 to 20006. This way the button poins to my macro. The macro works fine, but i get a strange issue with the button (the button led changes, but the button remains in down state). Here is a simple code:
- Code: Select all
if(AS3.Getbuttonstate(20006))
{
AS3.Switchbutton(false, 20006);
MessageBox.Show("False");
}
else
{
AS3.Switchbutton(true, 20006);
MessageBox.Show ("True");
}
Am i missing something?
Re: Get strange issue with toggle button.
Posted:
Tue May 15, 2018 12:21 pm
by ger21
Try this:
- Code: Select all
bool buttonstate = AS3.Getbuttonstate(20006);
if (buttonstate)
{
AS3.Switchbutton(false, 20006);
MessageBox.Show("False");
}
else
{
AS3.Switchbutton(true, 20006);
MessageBox.Show ("True");
}
Re: Get strange issue with toggle button.
Posted:
Tue May 15, 2018 1:20 pm
by dezsoe
I tried your original macro and the button works fine. Did you change the bitmap of the button?
Re: Get strange issue with toggle button.
Posted:
Tue May 15, 2018 1:22 pm
by kig23
Thanks Gerry. I've tried this befor, but the same issue. Thanks Dezsoe. No, i didn't change the bitmap of the original button, only redirect the button from 114 to 20006. Dezsoe, the button works and the led of the button too. The issue i'm geting is that the button remains in down sate. When the macro finishes if you click on g-code viewer the button goes to up state.
Re: Get strange issue with toggle button.
Posted:
Tue May 15, 2018 1:42 pm
by dezsoe
Hm. I tried again and no issues. I understood what you wrote for the first time, but could not make my PC to do the same. Which UCCNC version did you try?
Re: Get strange issue with toggle button.
Posted:
Tue May 15, 2018 2:03 pm
by kig23
Thanks Dezsoe. I've tried on vrsion 1.2047. I'm gonna try on other computer. I'll let you know.
Re: Get strange issue with toggle button.
Posted:
Tue May 15, 2018 2:10 pm
by cncdrive
I think that the problem is that the Messagebox is shown before the software could send the buttons up and it can't send the buttons up when the messagebox is active, because it blocks the Windows message pump.
Try to place a small value Thread.Sleep between the AS3.Switchbutton and MessageBox.Show codes or check if the button was released by the user using the Getbutton function, that shows you if the button is being pressed or not. And wait for the button to be released by the user and show the messagebox only then.
Re: Get strange issue with toggle button.
Posted:
Tue May 15, 2018 2:27 pm
by kig23
Thanks Balazs. Yes, you're right. With Thread.Sleep works fine. I'll try with Getbutton () too.
Thanks again