def isFocusWidget(): """ return true if the global qApp has any focused widgets """ focus = False if QApplication.instance(): if QApplication.instance().focusWidget(): window = QApplication.instance().focusWidget().window() geom = window.geometry() focus = geom.contains(QCursor.pos()) return focus
def isFocusWidget(): """ return true if the global qApp has any focused widgets """ focus = False if QApplication.instance(): if QApplication.instance().focusWidget(): window = QApplication.instance().focusWidget().window() geom = window.geometry() focus = not window.isMinimized() and geom.contains(QCursor.pos()) return focus
def consumeKey(ctxt, pressed): """ build the proper QKeyEvent from Softimage key event and send the it along to the focused widget """ kcode = ctxt.GetAttribute("KeyCode") mask = ctxt.GetAttribute("ShiftMask") # Build the modifiers modifier = Qt.NoModifier if mask and C.siShiftMask: if kcode + 300 in KEY_MAPPING: kcode += 300 modifier |= Qt.ShiftModifier if mask and C.siCtrlMask: modifier |= Qt.ControlModifier if mask and C.siAltMask: modifier |= Qt.AltModifier # Generate a Qt Key Event to be processed result = KEY_MAPPING.get(kcode) if result: if pressed: event = QKeyEvent.KeyPress else: event = QKeyEvent.KeyRelease if result[2]: modifier |= result[2] # Send the event along to the focused widget QApplication.sendEvent(QApplication.instance().focusWidget(), QKeyEvent(event, result[0], modifier, result[1]))
def consumeKey(ctxt, pressed): """ build the proper QKeyEvent from Softimage key event and send the it along to the focused widget """ kcode = ctxt.GetAttribute("KeyCode") mask = ctxt.GetAttribute("ShiftMask") # Build the modifiers modifier = Qt.NoModifier if mask & C.siShiftMask: if kcode + 300 in KEY_MAPPING: kcode += 300 modifier |= Qt.ShiftModifier if mask & C.siCtrlMask: modifier |= Qt.ControlModifier if mask & C.siAltMask: modifier |= Qt.AltModifier # Generate a Qt Key Event to be processed result = KEY_MAPPING.get(kcode) if result: if pressed: event = QKeyEvent.KeyPress else: event = QKeyEvent.KeyRelease if result[2]: modifier |= result[2] # Send the event along to the focused widget QApplication.sendEvent( QApplication.instance().focusWidget(), QKeyEvent(event, result[0], modifier, result[1]))