PushPickButton sample in C# (or any other language)

cant find a sample of code in order to figure out how to use it.

I have troubles understanding how to use the second argument, which is of type EventHandler.

I guess it is somehow a Method that It will associate to this PushPickButton, but… i’am lost!

I found several references in this forum directing to Dale Fugiers github page, but link seems to be broken.

So, please, could anybody show me any little sample code using PushPickButton?

thanks
leceta

The second argument is indeed a method that gets called when the button is pushed. An event handler has the following signature

Dialogs.PushPickButton(form, OnPickButtonPushed); // reference the function below

void OnPickButtonPushed(object sender, EventArgs args)
{
// do something here
}
1 Like

thanks Menno!

and there is no need to use the two arguments when OnPickbuttonPushed is called?

I guess I need to study how delegates work…

I found this piece of code that uses “showPickButton” by John Morse, in addition to Mennos sample. Thanks again, Menno.

Hi, I managed to make work my modal dialog with choosePickButton, but I noticed that once the user finishes the object selection process (in my case that was the purpose of choosePickButton method), Rhino UI is not fully locked, like it initially was.
Most of commands are not responsive, but for example, before closing the dialog, the user is able to create new layers. Am I missing something?

Not sure if I was clear enough with my explanation…
I meant, when ChoosePickButton method is finished and the process return to the parent modal form, I was expecting that Rhino’s interface to be locked as it was before using choosePickButton, but is not exactly fully locked, for example, model navigation is available, also some document editions commands, is the creation of new layers.
Is this the normal behavior?
any comment would be appreciated.
thanks.

Hi @aitorleceta,

Yes, I am able to reproduce this in Rhino 5. Rhino 6 appears to work as advertised.

If you don’t like the behavior of PushPickButton in V5, then you might implement your own version. An sample of similar behavior can be found here:

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModalForm.cs

– Dale

well, its not that a big issue to me, but generally I would prefer to have total control over the interface while editing a window from my plugin…i guess…

I will try to implement your example tomorrow.

thank you very much for your attention, @dale