I have read the article from http://developer.rhino3d.com/guides/grasshopper/extending-the-gui/
but still donnot know how to open a window By double click a component.because i am developing a gh component.
Can you give me a sample code in C# or VB(better C#)
Thankyou!
1 Like
There’s quite a lot to this, but these are the major steps required:
- Create a new class and derive it from
Grasshopper.Kernel.Attributes.GH_ComponentAttributes
.
- Override the
CreateAttributes()
method on your GH_Component
class, and assign a new instance of your own attributes to the m_attributes
class level field.
- In your own attributes class, override the
RespondToMouseDoubleClick()
method, and from there you can create all the windows you want.
2 Likes
thankyou,David,i will try it
David,i finish it,thank you for help. and there is another question:
After doubleclick the component,the form shows,and then,i input some number in textbox,then click OK,to change some data in component,but the text on component cannot refresh immediately,only after i move it or click the canvas then the component text refresh…so is there some method to refresh the component immediately?
Thank you!
OnDisplayExpired
can be used to refresh the canvas, but if you also need to update the solution after you close that window (or after you press OK), then you need to call ExpireSolution(true)
on the component. That will update both the solution and the canvas.
As I have observed, the redraw
parameter of OnDisplayExpired
will re-instantiate the component. Is that correct? If I do OnDisplayExpired(true)
, an async
method in my component seems to terminate. Same with RedrawCanvas
.