I want to create a component in grasshopperC# that can be linked to the keyboard and work like a button command.
For example, I want it to return true when the f8key is pressed, just like the button.
Has anyone made something like this before?
thank you
1 Like
check this…
f5_f6_f7_f8_insert_hotkey.gh (22.1 KB)
Scripts provided by @andheum and @Mahdiyar
[F7]
private void RunScript(object button, bool active, double increment, ref object A)
{
_btn = (GH_ButtonObject) button;
Instances.DocumentEditor.KeyDown -= new KeyEventHandler(KeyDownEventHandler);
Instances.DocumentEditor.KeyUp -= new KeyEventHandler(KeyUpEventHandler);
if(active)
{
Instances.DocumentEditor.KeyDown += new KeyEventHandler(KeyDownEventHandler);
Instances.DocumentEditor.KeyUp += new KeyEventHandler(KeyUpEventHandler);
}
}
// <Custom additional code>
GH_Bu…
PS: my definition with the sliders and buttons requires Metahopper.
1 Like