/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
bool qt_mac_eat_unicode_key = false;
extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); //qapplication_mac.cpp
-Q_GUI_EXPORT void qt_mac_secure_keyboard(bool b)
+Q_WIDGETS_EXPORT void qt_mac_secure_keyboard(bool b)
{
static bool secure = false;
if (b != secure){
static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent, int *qtKey,
QChar *outChar, Qt::KeyboardModifiers *outModifiers, bool *outHandled)
{
-#if !defined(QT_MAC_USE_COCOA) || defined(Q_OS_MAC64)
- Q_UNUSED(er);
- Q_UNUSED(outHandled);
-#endif
const UInt32 ekind = GetEventKind(keyEvent);
{
UInt32 mac_modifiers = 0;
rightShiftKey|alphaLock)) | keyCode,
&tmp_unused_state);
if (!translatedChar) {
-#ifdef QT_MAC_USE_COCOA
if (outHandled) {
qt_mac_eat_unicode_key = false;
if (er)
CallNextEventHandler(er, keyEvent);
*outHandled = qt_mac_eat_unicode_key;
}
-#endif
return false;
}
if (widget) {
-#ifndef QT_MAC_USE_COCOA
- Q_UNUSED(info);
- // Try not to call "other" event handlers if we have a popup,
- // However, if the key has text
- // then we should pass it along because otherwise then people
- // can use input method stuff.
- if (!qApp->activePopupWidget()
- || (qApp->activePopupWidget() && !text.isEmpty())) {
- //Find out if someone else wants the event, namely
- //is it of use to text services? If so we won't bother
- //with a QKeyEvent.
- qt_mac_eat_unicode_key = false;
- if (er)
- CallNextEventHandler(er, event);
- extern bool qt_mac_menubar_is_open();
- if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
- return true;
- }
- }
-#endif
// Try to compress key events.
if (!text.isEmpty() && widget->testAttribute(Qt::WA_KeyCompression)) {
EventTime lastTime = GetEventTime(event);
UInt32 macModifiers = 0;
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
sizeof(macModifiers), 0, &macModifiers);
-#ifdef QT_MAC_USE_COCOA
// The unicode characters in the range 0xF700-0xF747 are reserved
// by Mac OS X for transient use as keyboard function keys. We
// wont send 'text' for such key events. This is done to match
if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747)
text = QString();
bool isAccepted;
-#endif
handled_event = QKeyMapper::sendKeyEvent(widget, grab,
(ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress,
qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0,
macScanCode, macVirtualKey, macModifiers
-#ifdef QT_MAC_USE_COCOA
,&isAccepted
-#endif
);
-#ifdef QT_MAC_USE_COCOA
*unicodeKey = (unsigned int)isAccepted;
-#endif
}
return handled_event;
}
void
QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *
-#if defined(QT_MAC_USE_COCOA)
unicodeKey // unicode character from NSEvent (modifiers applied)
-#endif
)
{
UInt32 macVirtualKey = 0;
quint32 nativeModifiers, bool *isAccepted)
{
Q_UNUSED(count);
+ Q_UNUSED(grab);
+
if (widget && widget->isEnabled()) {
bool key_event = true;
-#if defined(QT3_SUPPORT) && !defined(QT_NO_SHORTCUT)
- if (type == QEvent::KeyPress && !grab
- && QApplicationPrivate::instance()->use_compat()) {
- QKeyEventEx accel_ev(type, code, modifiers,
- text, autorepeat, qMax(1, int(text.length())),
- nativeScanCode, nativeVirtualKey, nativeModifiers);
- if (QApplicationPrivate::instance()->qt_tryAccelEvent(widget, &accel_ev)) {
-#if defined(DEBUG_KEY_BINDINGS) || defined(DEBUG_KEY_BINDINGS_MODIFIERS)
- qDebug("KeyEvent: %s::%s consumed Accel: %s",
- widget ? widget->metaObject()->className() : "none",
- widget ? widget->objectName().toLatin1().constData() : "",
- text.toLatin1().constData());
-#endif
- key_event = false;
- } else {
- if (accel_ev.isAccepted()) {
-#if defined(DEBUG_KEY_BINDINGS) || defined(DEBUG_KEY_BINDINGS_MODIFIERS)
- qDebug("KeyEvent: %s::%s overrode Accel: %s",
- widget ? widget->metaObject()->className() : "none",
- widget ? widget->objectName().toLatin1().constData() : "",
- text.toLatin1().constData());
-#endif
- }
- }
- }
-#else
-Q_UNUSED(grab);
-#endif // QT3_SUPPORT && !QT_NO_SHORTCUT
if (key_event) {
#if defined(DEBUG_KEY_BINDINGS) || defined(DEBUG_KEY_BINDINGS_MODIFIERS)
qDebug("KeyEvent: Sending %s to %s::%s: %s 0x%08x%s",