RiverWare 6.5: DateTime Spinner Context Menu Enhancement (March 2014)
Phil Weinstein, CADSWES, edit: 3-25-2014
Project: BOR Truckee (Phil's March 2014 Tasks)
![]() |
|
![]() |
The original request was to add "Global Scroll" functionality to the Open Object Dialog's Date/Time spinner. This has been addressed by implementing a custom context menu for all RiverWare Date/Time spinners. The new menu starts with a "Global Time Scroll" operation.
A custom context menu is now provided by overriding the QSpinBox's child QLineEdit's context menu implementation. This necessarily loses the two operations which the QSpinBox had added to that context menu: "Step Up" and "Step Down".
Additionally, we have hidden the following operations in the QLineEdit's standard context menu:
So now, the Date/Time spinner context menu consists of the following operations. (Note that "Copy" and "Paste" apply to the selected text within the spin box text):
Note: There seems to be an intermittent bug in Qt 4.8.5 where accelerator keys don't always show up in the QSpinBox's context menu. For example, notice that only in one of the two accompanying images does the "Select All" operation indicate an accelerator key combination of "Ctrl+A". The appearance of that is apparently intermittent. We've seen this also for the "Copy" operation's "Ctrl+C" accelerator key combination.
Technical: This was implemented by adding an event filter to the QSpinBox's child QLineEdit widget. When a QEvent::ContextMenu event is received, a custom context menu is created, modified, and "popped up" -- in place of the standard processing of that event. See methods: DateTimeQtSpinner::LineEditEventFilter::eventFilter() and ::showContextMenu().
---