tom33
(Ye lin a)
January 3, 2026, 4:33am
1
My KeyDown seems to be ineffective. It seems that I have done something wrong.
#! python 3
import Eto.Forms as ef
import Eto.Drawing as ed
import Rhino as rh
class From(ef.Form):
def __init__(self):
super().__init__()
self.Size = ed.Size(200,200)
self.KeyDown += self.OnKeyDownEvent
def OnKeyDownEvent(self,sender, e):
try:
print(f"Test:{e.Key}")
except Exception as ex:
rh.RhinoApp.WriteLine(f"Error in OnKeyDown: {ex}")
if __name__ == "__main__":
form = From()
form.Show()
You may need to click on the form or give it focus.
Adding this to the __init__ means I don’t need to click it first.
self.Focus()
tom33
(Ye lin a)
January 3, 2026, 5:28pm
3
I made the following modifications to this, but my “KeyDown” still cannot monitor keyboard information.
#! python 3
import Eto.Forms as ef
import Eto.Drawing as ed
import Rhino as rh
class From(ef.Form):
def __init__(self):
super().__init__()
self.Size = ed.Size(200,200)
self.Focus()
self.KeyDown += self.OnKeyDownEvent
self.MouseEnter += self.OnMouseEnterEvent
def OnKeyDownEvent(self,sender, e):
try:
print(f"Test:{e.Key}")
except Exception as ex:
rh.RhinoApp.WriteLine(f"Error in OnKeyDown: {ex}")
def OnMouseEnterEvent(self,sender, e):
try:
print("MouseEnter")
self.Focus()
except Exception as ex:
rh.RhinoApp.WriteLine(f"MouseEnter: {ex}")
if __name__ == "__main__":
form = From()
form.Show()
Huh, on Windows this doesn’t capture any keys. I did the earlier one on Mac assuming they’d be identical. Not sure why right now, I’ll keep testing.
@curtisw would know for certain.
Hi @tom33 ,
import Eto.Forms as ef
import Eto.Drawing as ed
import Rhino
class MyForm(ef.Form):
def __init__(self):
super(MyForm, self).__init__()
self.Title = "Key Test"
self.Size = ed.Size(200, 200)
drawable = ef.Drawable()
drawable.CanFocus = True
drawable.KeyDown += self.OnKeyDownEvent
self.Content = drawable
def OnKeyDownEvent(self, sender, e):
Rhino.RhinoApp.WriteLine("Key pressed: {0}".format(e.Key))
e.Handled = True
if __name__ == "__main__":
form = MyForm()
form.Owner = Rhino.UI.RhinoEtoApp.MainWindow
form.Show()
Hope this clarifies any doubts,
Farouk