mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 10:24:45 +08:00
Properly handle Escape key in native Window event handling function if event WM_EXITSIZEMOVE occurs
This commit is contained in:
parent
277e06627b
commit
dfb8543aee
@ -57,6 +57,7 @@
|
|||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
#if 0 // set to 1 if you need this function for debugging
|
||||||
/**
|
/**
|
||||||
* Just for debuging to convert windows message identifiers to strings
|
* Just for debuging to convert windows message identifiers to strings
|
||||||
*/
|
*/
|
||||||
@ -350,6 +351,7 @@ static const char* windowsMessageString(int MessageId)
|
|||||||
return "unknown WM_ message";
|
return "unknown WM_ message";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static unsigned int zOrderCounter = 0;
|
static unsigned int zOrderCounter = 0;
|
||||||
@ -713,7 +715,6 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
|
|||||||
if (d->isState(DraggingMousePressed))
|
if (d->isState(DraggingMousePressed))
|
||||||
{
|
{
|
||||||
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_ENTERSIZEMOVE" << e->type());
|
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_ENTERSIZEMOVE" << e->type());
|
||||||
qApp->installEventFilter(this);
|
|
||||||
d->setState(DraggingFloatingWidget);
|
d->setState(DraggingFloatingWidget);
|
||||||
d->updateDropOverlays(QCursor::pos());
|
d->updateDropOverlays(QCursor::pos());
|
||||||
}
|
}
|
||||||
@ -722,8 +723,15 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
|
|||||||
case WM_EXITSIZEMOVE:
|
case WM_EXITSIZEMOVE:
|
||||||
if (d->isState(DraggingFloatingWidget))
|
if (d->isState(DraggingFloatingWidget))
|
||||||
{
|
{
|
||||||
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE" << e->type());;
|
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE" << e->type());
|
||||||
d->titleMouseReleaseEvent();
|
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000)
|
||||||
|
{
|
||||||
|
d->handleEscapeKey();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d->titleMouseReleaseEvent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -796,43 +804,6 @@ void CFloatingDockContainer::showEvent(QShowEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *e)
|
|
||||||
{
|
|
||||||
Q_UNUSED(watched);
|
|
||||||
// I have not found a way to detect non client area key press events to
|
|
||||||
// handle escape key presses. On Windows, if the escape key is pressed while
|
|
||||||
// dragging around a widget, the widget position is reset to its start position
|
|
||||||
// which in turn generates a QEvent::NonClientAreaMouseButtonRelease event
|
|
||||||
// if the mouse is outside of the widget after the move to its initial position
|
|
||||||
// or a QEvent::MouseButtonRelease event, if the mouse is inside of teh widget
|
|
||||||
// after the position has been reset.
|
|
||||||
// So we can install an event filter on the application to get these events
|
|
||||||
// here to properly cancel dragging and hide the overlays.
|
|
||||||
// If we are in DraggingFloatingWidget state, it means the widget
|
|
||||||
// has been dragged already but if the position is the same like
|
|
||||||
// the start position, then this is an indication that the escape
|
|
||||||
// key has been pressed.
|
|
||||||
if (e->type() == QEvent::MouseButtonRelease || e->type() == QEvent::NonClientAreaMouseButtonRelease)
|
|
||||||
{
|
|
||||||
ADS_PRINT("CFloatingDockContainer::eventFilter QEvent::MouseButtonRelease or"
|
|
||||||
"QEvent::NonClientAreaMouseButtonRelease" << "d->DragggingState " << d->DraggingState);
|
|
||||||
qApp->removeEventFilter(this);
|
|
||||||
if (d->DragStartPos == pos())
|
|
||||||
{
|
|
||||||
d->handleEscapeKey();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (ADS_DEBUG_LEVEL > 0)
|
|
||||||
qDebug() << QTime::currentTime() << "CFloatingDockContainer::eventFilter " << e->type();
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
|
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
|
||||||
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
|
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
|
||||||
|
@ -180,7 +180,6 @@ protected: // reimplements QWidget
|
|||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual void hideEvent(QHideEvent *event) override;
|
virtual void hideEvent(QHideEvent *event) override;
|
||||||
virtual void showEvent(QShowEvent *event) override;
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user