-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the ALT key still gets stuck sometimes #60
Comments
had the same happen with the CTRL key |
when alt tabbing to another app. and back to blender, the alt key appears to not get stuck. 100 % REPRO |
❌ tried event simulate from blender bpy.types.Window.event_simulate('LEFT_ALT', 'RELEASE')
# AttributeError: type object 'Window' has no attribute 'event_simulate' needs to run on instance new_window.event_simulate('LEFT_ALT', 'RELEASE')
# RuntimeError: Error: Not running with '--enable-event-simulate' enabled |
@bob-white linked this https://github.com/qtproject/qt-solutions/tree/master/qtwinmigrate
|
current workaround: disable qt wrapping with |
some keys get stuck on alt tab or window focus change. we successfullly force a release from stuck keys when changing focus from blender to another app and back. but not yet from blender to blender. on QApp init, we connect # win32 implementation
def _on_focus_object_changed(self, focus_object: QObject):
"""
Args:
QObject focus_object: Object to track focus change
"""
if focus_object is self.blender_widget:
ctypes.windll.user32.SetFocus(self._hwnd)
bqt.focus._detect_keyboard(self._hwnd)
@staticmethod
def _detect_keyboard():
"""
force a release of 'stuck' keys
"""
# key codes from https://itecnote.com/tecnote/python-simulate-keydown/
keycodes = [
("_ALT", 0x12),
("_CTRL", 0x11),
("_SHIFT", 0x10),
("VK_LWIN", 0x5B),
("VK_RWIN", 0x5C),
("OSKEY", 0x5B), # dupe oskey, blender names it this
]
# print("event.type", event.type, type(event.type))
for name, code in keycodes:
# todo this bug fix is not perfect yet, blender works better without this atm
# # if the first key pressed is one of the following,
# # don't simulate a key release, since it causes this bug:
# # the first keypress on re-focus blender will be ignored, e.g. ctrl + v will just be v
# if name in event.type:
# print("skipping:", name)
# continue
# safely release all other keys that might be stuck down
ctypes.windll.user32.keybd_event(code, 0, 2, 0) # release key
# print("released key", name, code)
# todo, fix: blender occasionally still frozen input, despite having run the above code
# but when we click the mouse, it starts working again
# simulate a right mouse click did not work ...
# ctypes.windll.user32.mouse_event(0x0008, 0, 0, 0, 0) # right mouse click |
|
a fix went in #32
but sometimes this bug still happens.
pressing ALT once fixes the bug.
The text was updated successfully, but these errors were encountered: