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

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

Detection transaction operation

Postby caramel » Tue Jan 09, 2018 8:22 pm

Hi,

I'm using transaction listener for change detection :

Code: Select all

TransactionListener.init = function (basePath) {

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

  adapter.transactionUpdated.connect(function (document, transaction) {
    if (isNull(document) || isNull(transaction)) {
      return;
    }
   
    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");
          //mycode...
        }

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

      }
    }

  });

  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 !
Caramel

Return to “QCAD Developers and Contributors”

Who is online

Users browsing this forum: No registered users and 1 guest