Grasshopper

algorithmic modeling for Rhino

Hello,

Is there a way to set the cursor in c#?

I've been trying to implement a conditional cursor by creating a cursor object and then assigning the type (ie. cur = Cursors.Hand) but I have not been successful in having it render in the viewport.

Does anyone have a piece of sample code that they would mind sharing or provide advice or suggestions to help? Maybe there is a cursor override that I don't know about or should I explore tool tips?  Tool tips appeared not to control the style (for example - a hand cursor) but rather enable a text interface - I think.

Views: 758

Replies to This Discussion

Cursors are assigned per control usually. So for which control do you want to modify the cursor? Rhino viewport? GH canvas? A control on your own form?

David,

The rhino viewport. Any help about where I find access to and set the viewport cursor is appreciated.

Ah, I do not know if (and how) you can change the cursor of the Rhino viewports via RhinoCommon. You'll have to ask on our discourse forum where all the SDK developers hang out.

Thanks David - Will give it a go.

David,

A need had arisen for understanding more about cursor styles in the canvas environment.

As per above I'm interested in generating a mouse over that transforms the cursor to a hand. Where should I start to look for examples (if they exist).  

The mouse over will work with a button on a component.

If you're dealing with .NET controls then assigning cursors can be done via regular .NET framework methods, however I simplified the process with the GH_CursorServer class. This static class loads all cursor files (*.cur) from a folder and then you can assign them to controls by name.

Call this when your plugin loads:

Grasshopper.GUI.GH_CursorServer.ReferenceCursors(myFolderWithCursors);

And then at runtime:

Grasshopper.GUI.GH_CursorServer.AttachCursor(canvas, "Hand");

...

Grasshopper.GUI.GH_CursorServer.ResetCursor(canvas);

You can also use the already existing hand cursor that comes with Grasshopper then call AttachCursor with "GH_HandPan".

Incidentally you can turn regular images into *.cur files with the free Paint.NET app.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service