Detection transaction operation

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

Moderator: andrew

Post Reply
Newbie Member
Posts: 4
Joined: Mon Jan 08, 2018 7:01 pm

Detection transaction operation

Post by caramel » Tue Jan 09, 2018 8:22 pm


I'm using transaction listener for change detection :

Code: Select all

TransactionListener.init = function (basePath) {

  var adapter = new RTransactionListenerAdapter();
  var appWin = EAction.getMainWindow();

  adapter.transactionUpdated.connect(function (document, transaction) {
    if (isNull(document) || isNull(transaction)) {
    var doc = EAction.getDocument();
    var objIds = transaction.getAffectedObjects();

    for (var i = 0; i < objIds.length; i++) {
      var objId = objIds[i];     

      var obj = doc.queryObjectDirect(objIds[i]);

      if (isLineEntity(obj)) {
        if (transaction.getText().toLowerCase() == "supprimer") {
          qDebug("line deleted");

        else if (transaction.getText().toLowerCase().indexOf("déplacer") != -1) {          
          qDebug("line moved");   



  EAction.handleUserMessage("Mod_TransactionListener.js: Transaction listener installed.");

And as you can see I'm temporarily basing on transaction.getText() to detect operation type, but I know that isn't the appropriate way, could you tell me the rightr way to detect it ?

Thanks a lot !

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

Re: Detection transaction operation

Post by andrew » Mon Mar 12, 2018 12:53 pm

There is no transaction type as such. A transaction encapsulates a change in the drawing (changing objects, adding objects, removing objects). Transactions are unaware of the particular tool that was used to cause that change (apart from the transaction text which can be optionally set by the tool responsible for the transaction).

transaction.getAffectedObjects() returns a list of object IDs of objects that were changed / added/ deleted by a transaction.
transaction.getStatusChanges() returns a list of object IDs of objects that were either created or deleted (check undo status of object)
transaction.getPropertyChanges() returns a list of exact property changes per object as shown in ExTransactionListener.

Post Reply

Return to “QCAD Developers and Contributors”