OK, I wrote a quick test plugin. The Buttonpress_event contains the following lines:
- Code: Select all
DebugInfo("Button pressed: " + ButtonNumber.ToString());
if (ButtonNumber == 1)
UC.Callbutton(10670);
And here are the results after creating a button using button number 1, pressing reset, home all and then the new button:
- Code: Select all
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 144
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 113
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 1
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 10670
Notes:
- DebugInfo writes to the console.
- The name of the event handler is different, but it is called by the Buttonpress_event in a try-catch.
- Button 10670 was "pressed" by the Callbutton.
Writing about the try-catch: if your plugin throws an exception in the Buttonpress_event then you'll have the same result as if the event wasn't called. Try to catch exceptions in your handler, maybe, that is the problem.
- Code: Select all
public void Buttonpress_event(int ButtonNumber, bool OnScreen)
{
try
{
// Do your stuff here
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}