Grasshopper

algorithmic modeling for Rhino

Left-mouse button event-arg in C#/VS component (as opposed to right-mouse event)

Currently, this is the method I use in one of my components to trigger an action and event:

It is called within my AppendMenuItems(ToolStripDropDown menu) { .. } like so:

My question is -- in the context of my code, how do I change its activation to a left-mouse button single click as opposed to a right-click which it currently is? Thank you.

Views: 1053

Replies to This Discussion

There could not possibly be any reason to cache the sender and the eventargs for this mouse click. The menu and all items it contains is constructed just prior to showing and destroyed immediately after you click on an item.

Also, once an item has been clicked, the menu will be hidden and destroyed, so checking the item at this stage is pointless as nobody will ever see the item again.

ToolstripMenuItems respond identically to left clicks and right clicks in Grasshopper, is this not the case for you?

--

David Rutten

david@mcneel.com

Is that just popup menus for components, or all menus in Grasshopper?

--

David Rutten

david@mcneel.com

Ah opening the menu with left click! I thought you were talking about left or right clicking the items in the menu.

In that case you'll have to override the attributes of the component. It's no longer enough to just populate the menu. Once you have replaced the default attributes with your own, you can handle the mouse-click event. The SDK Help has examples in VB and C# on how to assign custom attributes.

--

David Rutten

david@mcneel.com

--

David Rutten

david@mcneel.com

You have to override the RespondToXXXX() method you want to change and then in there create menu, show it and return the Handled flag.

--

David Rutten

david@mcneel.com

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service