AnsweredAssumed Answered

Events that use RegisterCommand stop to work after mode change. Why is that ?

Question asked by peter_festesen on Nov 1, 2019

This question is regarding the behavior of the Event Handling when changing modes in Xpedition (Draw/Place/Route). 

It appears that what I call the built-in events like doc_OnRButtonClk, it will work even after switching between modes. It is declared this way (full test script can be uploaded if needed) : 

Call Scripting.AttachEvents(doc, "doc")
If Err Then
      app.Gui.Display("Error creating event handler for doc " + Err.Description)
End If

 

Scripting.DontExit = True     

..

..

Function doc_OnRButtonClk(eFlags, dX, dY)

     MsgBox "RMB"

End Function

 

But events that are handled via RegisterCommand seize to work after switching modes. 

Example msKey  - Main script has : 

Set msKey = expApp.Gui.RegisterCommand("Press Key", True)
Call Scripting.AttachEvents(msKey, "msKey")

'Call Scripting.AttachEvents(expDoc, "doc")

'*****************************************************************************************
Scripting.DontExit = True ' Keep on running

 

...

...

Function msKey_OnChar(nChar)' As Boolean

MsgBox "Keypress " & nchar

End Function

 

The same is true for another event that uses Mouseclick. 

 

If I reload the entire script after switching mode, it works again (of course it does) - but I wonder if there is a good reason for it to stop when switching mode ? 

 

If so

- what is needed to get it to work even after mode switching - re-registration of all events ? 

- Is there an event that is fired when the mode changes (I tried to find one , but nothing jumped at me) ? 

 

/P 

 

Outcomes