I wanted to skip a tool state when indicating a coordinate while pressing down the Shift key.
The action then used some default behavior instead of an extra user input.
But that failed already for the Alt key functionality when that key is pressed at the same time.
This duality is simply not supported throughout QCAD.
RDocumentInterface.mouseReleaseEvent(event) with an existed RAction
Where the event is an RMouseEvent.
- Triggers in this order:
- RAction.mouseReleaseEvent(event)
- RDocumentInterface.handleClickEvent(RAction, event)
Eventually this calls the PickCoordinate function of our tool.
When both Alt and Shift are pressed it is not handled as a PickCoordinate.
-> The indicated position is not snapped orthogonal in regards with the relative zero (preview or final).
-> No action takes place on clicking and if so, the tool state is not advanced.
Also see standard implementation current Line 973-976.
The event.modifiers() must exactly match with Qt::AltModifier or with Qt::ShiftModifier, not with a combination of the two.
The solution sits in that the RMouseEvent keyboard modifiers are passed on to an RCoordinateEvent.
Remark that the modifiers are delegated as they are but it is the coordinate picking that is not preformed.
We can strip the Qt.ShiftModifier from the RMouseEvent and store that in a local flag before the handleClickEvent is called.
In our tool ('Dummy') its mouseReleaseEvent we catch the duality.
When a preview is generated on hovering we do the same in the mouseMoveEvent.
After that we can handle our local flag in the PickCoordinate separately just the way we like.

While Alt-snapping and coordinate clicking are handled as expected.
Code: Select all
Dummy.prototype.mouseMoveEvent = function(event) {
// No default implementation in EAction
// Allow Qt.ShiftModifier and Qt.AltModifier at the same time:
this.fixKeyboardModifiers(event);
};
Dummy.prototype.mouseReleaseEvent = function(event) {
// Call default implementation:
// Acts on releasing the right mouse button = Cancel
EAction.prototype.mouseReleaseEvent.call(this, event);
// Allow Qt.ShiftModifier and Qt.AltModifier at the same time:
this.fixKeyboardModifiers(event);
};
// Helper function to allow Qt.ShiftModifier and Qt.AltModifier at the same time
Dummy.prototype.fixKeyboardModifiers = function(event) {
// # Issue Fixed # Qt.ShiftModifier + Qt.AltModifier is not handled in RDocumentInterface.handleClickEvent
// -> Not acting on Alt to snap orthogonal
// -> Not acting on picking a coordinate by mouse
var mod = getKeyboardModifiers(event);
var shiftPressed = (mod.valueOf() & Qt.ShiftModifier.valueOf()) > 0;
var altPressed = (mod.valueOf() & Qt.AltModifier.valueOf()) > 0;
// Synchronize local flag:
this.shiftPressed = shiftPressed;
// Clear duality of the RMouseEvent modifiers, later adopted in an RCoordinateEvent:
if (shiftPressed && altPressed) {
event.setModifiers(Qt.AltModifier);
// Also sets Qt.NoModifier what is zero
}
};
CVH