Cocoa combo box drop down resets when background tasks running and mouse tracking prevents syncing
Original Reporter info from Mantis: djenkins @dfjenkins
-
Reporter name: David Jenkins
Original Reporter info from Mantis: djenkins @dfjenkins
- Reporter name: David Jenkins
Description:
If background tasks are running, combobox dropdowns will not stay down but close back up. If the dropdown is forced to stay down then the additional problem of mouse tracking loops preventing background syncing is exhibited.
Steps to reproduce:
Run background thread that synchronized to foreground such that TCocoaWidgetSet.SendCheckSynchronizeMessage() is periodically called (Application.QueueAsyncCall from background thread will do this). Then try to open a combobox.
Attached example project mouseback.zip does this.
Additional information:
The problem is that NSComboBoxCell.popup calls NSComboBoxCell.filterEvent which calls NSApplication.nextEventMatchingMask:untilDate:inMode:dequeue() to watch for keyboard/mouse/gesture events to indicate that editing/selection in the combobox has finished and the dropdown should close.
The NSApplicationDefined event that is sent off by TCocoaWidgetSet.SendCheckSynchronizeMessage() is caught and interpreted as a editing done event and the dropdown is closed.
Since nextEventMatchingMask is already overridden in CocoaInt, the offending message can be caught there (move the code up from TCocoaWidgetSet.AppWaitMessage and TCocoaWidgetSet.AppProcessMessages) and then return Result = nil.
This fixes the problem with the drop down but it then exposes the problem that background syncing does not work during the mouse tracking loop (see lcl/interfaces/carbon/carbonobject.EventTimerCallback). The NSComboBoxCell.filterEvent() keeps looping on nextEventMatchingMask waiting for input to close the dropdown and Applicaiton.ProcessAsyncCallQueue is never called.
Suggested fix is to add call to Application.ProcessAsynCallQueue to TCocoaApplication.nextEventMatchingMask_untilDate_inMode_dequeue(). This is done in the same spot where the NSApplicationDefined event is caught and CheckSynchronize is called (moved here in above step).
A patch is attached.
Mantis conversion info:
- Mantis ID: 35547
- Version: 2.0.3 (SVN)
- Fixed in revision: 61207 (#e1fb95fb)