Hello,
I have this bit of code:
# self.CreateSearchBox() # Call To Create SearchBox Instance
self.CreateUI() # Call Initially To Create Background UI
# Initialize a flag to keep track of Ctrl key state
self.ctrl_pressed = False
# Create the key listener
self.CreateKeyListener()
def CreateKeyListener(self):
self.KeyDown += self.OnKeyDown # Subscribe to KeyDown event
self.KeyUp += self.OnKeyUp # Subscribe to KeyUp event
def OnKeyDown(self, e):
try:
if e.Key == Eto.Forms.Keys.LeftControl:
self.ctrl_pressed = True # Set the flag to True when Ctrl is pressed
except Exception as ex:
Rhino.RhinoApp.WriteLine(f"Error in OnKeyDown: {ex}")
def OnKeyUp(self, e):
global show_tray
global show_search
try:
if e.Key == Eto.Forms.Keys.F and self.ctrl_pressed:
self.ctrl_pressed = False
self.update_button_state(1, True)
show_search = show_tray = True
self.CreateUI()
elif e.Key == Eto.Forms.Keys.Escape:
self.update_button_state(1, False)
show_search = show_tray = False
self.CreateUI()
except Exception as ex:
Rhino.RhinoApp.WriteLine(f"Error in OnKeyUp: {ex}")
That “expands” my UI when the mouse is over the Form AND Ctrl+F is pressed.
Hitting Escape will “contract” close the expanded UI.
My question is, while I like that this allows me to have focus on my form and doesn’t effect the viewport having focus to be able to select things/do things, can I listen for this shortcut without needing to have my Eto.Form in focus/being hovered on?
Thanks for any guidance!