RhinoCommon GetPoint: listener for key press or mouse wheel

Hi,

I have a python function using Rhino.Input.Custom.GetPoint, so the user can pick the position of a gemstone on a surface.
I would like to make it possible for the user to use their keyboard or mouse wheel to tune the size of the gemstone while picking the point.

I see in GetPoint API that there are events only for mouse clicks and mouse moves…

Rhino.RhinoApp.KeyboardEvent looks like the way to go, but the following code does not trigger anything on key press :

import Rhino

def key_pressed(key):
    print(key)

Rhino.RhinoApp.KeyboardEvent += key_pressed
import Rhino
import scriptcontext as sc

class KeyboardEventHandler():
    def __init__(self):
        Rhino.RhinoApp.KeyboardEvent += self.event

    
    def event(self, key):
        if key == 16: # SHIFT
            print('increase')
        elif key == 17: # CONTROL
            print('decrease')

def obj_event_helper_func(sticky_key):
    if not sc.sticky.has_key('my-event'):
        stky = KeyboardEventHandler()
        sc.sticky[sticky_key] = stky

obj_event_helper_func('my-event')
1 Like

I was recently working on something similar in C# so i had to do some reading on the topic of catching mouse events. Here is an example I came across in python, if you are still considering useing the mousewheel.

1 Like