Events documentation

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Events documentation

Post by CVH » Fri Mar 12, 2021 2:55 pm

Andrew,

In general:
I there a list of standard events that occur in a QCAD installation?

With merging some methods from BreakOutManual.js into PolyLineBreakSymbol.js there are things I don't understand yet.
Reading https://www.ribbonsoft.com/en/tutorial- ... pt-actions
clarified some but one eludes me for this script.

PolyLineBreakSymbol.js sets RAction.PickCoordinate.
I understand while hovering there are coordinateEvent happening,
.. that the getOperation is called on updatePreview() and is only used to preview.

What is not explained is that coordinateEventPreview is actually making a choise also.
Seems that PickCoordinate = coordinateEvent and on pick also a coordinateEventPreview.

Kind regards,
CVH

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Events documentation

Post by andrew » Wed Mar 17, 2021 12:33 pm

After a this.getDocumentInterface().setClickMode(RAction.PickCoordinate)

Code: Select all

coordinateEvent
by default triggers

Code: Select all

pickCoordinate(event, /*preview=*/ true)
as long as the user is previewing the result (i.e. mouse move) and

Code: Select all

pickCoordinate(event, /*preview=*/ false)
when the user picks a definitive coordinate.

After this.getDocumentInterface().setClickMode(RAction.PickEntity)

entityPickEvent does the same with pickEntity(event, true | false);

Typically, an action would implement pickCoordinate to define coordinates and pickEntity to choose entities, but you can also implement and override coordinateEvent or even mousePressEvent, mouseReleaseEvent and mouseMoveEvent, depending on how low-level you need your interaction.

getOperation should return the best possible implementation of an operation at the current stage of the action to either show a preview (preview = true) or to execute the action (preview = false).

To show the preview at any stage (while hovering over an entity or point), the action should call updatePreview() which calls getOperation(true) and previews the operation.

To apply the operation (after picking the final coordinate or entity), the action should call applyOperation() which calls getOperation(false) and applies the operation.

All this is implemented in EAction and can be overwritten by the action if desired.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”