QMouseEvent with delay
-
Qt 5.15. Windows.
I have a QMouseEvent (left button press). I'm trying to add a delay.
I save the mouse event and assert that the left button is pressed.
After a delay, just before passing it on to lower level code to be acted upon, I check the saved mouse event, and it still has the same pointer, but the left button is no longer pressed.saving the mouse press
m_pMousePressEvent = pEvent; assert((m_pMousePressEvent->button() == Qt::LeftButton));
Testing the event a half second later
assert(m_pMousePressEvent->button() == Qt::LeftButton);
Even when the button is still pressed.
Anyone have any idea what is going on?
According to the debugger, the value is changed here:
> CoreUIComponents.dll!Microsoft::CoreUI::Formatting::CnSerialize::InitializeMethod(class Microsoft::CoreUI::MessagingInterop::MessageFactory *,class Microsoft::CoreUI::MessagingInterop::IMessagePort *,enum Microsoft::CoreUI::Formatting::CnSerialize::MessageKind,struct Cn::TypeExtra_Reflection const *,unsigned short,enum Microsoft::CoreUI::Formatting::CnSerialize::InitializeIntent) Unknown CoreUIComponents.dll!Microsoft::CoreUI::Proxy::MessageProxy::Send() Unknown CoreUIComponents.dll!Proxy_IRemoteTextInputServer$R::IRemoteTextInputServer_Impl::InputHostFocusLeave(class System::Object *,unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool) Unknown CoreUIComponents.dll!IRemoteTextInputServer::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool) Unknown CoreUIComponents.dll!IRemoteTextInputServer$X__ExportAdapter::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool) Unknown TextInputFramework.dll!TextInputHost::InputHostFocusLeave() Unknown TextInputFramework.dll!TextInputHost::PutHasFocusInternal() Unknown msctf.dll!CThreadInputMgr::OnInputFocusEvent(unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long) Unknown msctf.dll!CThreadInputMgr::OnCiceroEvent() Unknown msctf.dll!WinEventProc(struct HWINEVENTHOOK__ *,unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long) Unknown user32.dll!__ClientCallWinEventProc() Unknown ntdll.dll!KiUserCallbackDispatcherContinue() Unknown win32u.dll!NtUserPeekMessage() Unknown user32.dll!_PeekMessage() Unknown user32.dll!PeekMessageW() Unknown Qt5Core.dll!QEventDispatcherWin32::processEvents() + 766 bytes Unknown qwindows.dll!qt_plugin_query_metadata() + 8089 bytes Unknown Qt5Core.dll!QEventLoop::exec() + 444 bytes Unknown Qt5Core.dll!QCoreApplication::exec() + 340 bytes Unknown
-
Qt 5.15. Windows.
I have a QMouseEvent (left button press). I'm trying to add a delay.
I save the mouse event and assert that the left button is pressed.
After a delay, just before passing it on to lower level code to be acted upon, I check the saved mouse event, and it still has the same pointer, but the left button is no longer pressed.saving the mouse press
m_pMousePressEvent = pEvent; assert((m_pMousePressEvent->button() == Qt::LeftButton));
Testing the event a half second later
assert(m_pMousePressEvent->button() == Qt::LeftButton);
Even when the button is still pressed.
Anyone have any idea what is going on?
According to the debugger, the value is changed here:
> CoreUIComponents.dll!Microsoft::CoreUI::Formatting::CnSerialize::InitializeMethod(class Microsoft::CoreUI::MessagingInterop::MessageFactory *,class Microsoft::CoreUI::MessagingInterop::IMessagePort *,enum Microsoft::CoreUI::Formatting::CnSerialize::MessageKind,struct Cn::TypeExtra_Reflection const *,unsigned short,enum Microsoft::CoreUI::Formatting::CnSerialize::InitializeIntent) Unknown CoreUIComponents.dll!Microsoft::CoreUI::Proxy::MessageProxy::Send() Unknown CoreUIComponents.dll!Proxy_IRemoteTextInputServer$R::IRemoteTextInputServer_Impl::InputHostFocusLeave(class System::Object *,unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool) Unknown CoreUIComponents.dll!IRemoteTextInputServer::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool) Unknown CoreUIComponents.dll!IRemoteTextInputServer$X__ExportAdapter::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool) Unknown TextInputFramework.dll!TextInputHost::InputHostFocusLeave() Unknown TextInputFramework.dll!TextInputHost::PutHasFocusInternal() Unknown msctf.dll!CThreadInputMgr::OnInputFocusEvent(unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long) Unknown msctf.dll!CThreadInputMgr::OnCiceroEvent() Unknown msctf.dll!WinEventProc(struct HWINEVENTHOOK__ *,unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long) Unknown user32.dll!__ClientCallWinEventProc() Unknown ntdll.dll!KiUserCallbackDispatcherContinue() Unknown win32u.dll!NtUserPeekMessage() Unknown user32.dll!_PeekMessage() Unknown user32.dll!PeekMessageW() Unknown Qt5Core.dll!QEventDispatcherWin32::processEvents() + 766 bytes Unknown qwindows.dll!qt_plugin_query_metadata() + 8089 bytes Unknown Qt5Core.dll!QEventLoop::exec() + 444 bytes Unknown Qt5Core.dll!QCoreApplication::exec() + 340 bytes Unknown
After a delay,
How do you implement this? Do you mean you set off a
QTimer
and allow the original event to exit, or do you mean you put a blocking loop in and stay in original event?but the left button is no longer pressed.
Even when the button is still pressed.
Maybe someone else does understand, but I do not know what to make of these two statements.
You save a
QEvent *
(pointer) inm_pMousePressEvent
. Depending on your answers to proceeding questions, how do you know whether the original event pointed to which you have saved is either still valid or has/has not had its content overwritten? -
Actually, I suspect that the original mouse event is being deleted and I need to copy the event and not just the pointer.
@james-b-s
That would be my thought! As I said depends whether you stay in original event handler or exit it and it gets called again. I don't think Qt guarantees aQEvent
will live longer than the handler it is passed to, else when would it get deleted? If the same memory area happens to get re-used for subsequent events then your retained pointer may actually point to new event information. Copy the event (if it's copyable) or at least the bits inside it you want to know about if you need to access it later on. -
The event object documents the state of the system at the time of the event generation, not at the time of examination. Saving it to examine later won't tell the application anything about the system at that later point.
Have you seen QGuiApplication::mouseButtons()?
-
Actually, I suspect that the original mouse event is being deleted and I need to copy the event and not just the pointer.
Just curious:
Where do you click and what do you want to do with that information/delay?
Maybe there's a better way to achieve this