internal command button events

internal command button events

Anonymous
Not applicable
833 Views
2 Replies
Message 1 of 3

internal command button events

Anonymous
Not applicable
Hi,
in an addin i have some userdefined buttons created.
-Create Buttondefinition with .add
-Create event sink
-Write a _onexcute sub
This works fine.

Now I Want to do same same with an internal command.

'buttons
Private oMyButton As Inventor.ButtonDefinition

oMyButton = oControlDefs.item("AppFilePrintCmd")

'connect the button event sink
AddHandler oMyButton.OnExecute, AddressOf
Me.MyButton_OnExecute

Private Sub MyButton_OnExecute(ByVal Context As NameValueMap)

'MsgBox("Hello")

end sub

The buttondfinition is ok.
I can access the properties of the builtin Command for example "DisplayName"

The event sink seems to be ok too.
No errors occurs.

But it seems, that the procedur Mybutton_onexecute
is not executed when the button gets a click.

So my question is, what is going wrong?
I suggest, that inventor does not execute this because an internal command cannot be overrided by user code.
But what can I do to get the information that the user clicks the button?
I want to do something before the command is executed
and then excute the command.
I my case I want to write a time stamp on a sheet before
the AppFilePrintCmd Command is executed.

Manfred
0 Likes
834 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
As you've found, the OnExecute event does not fire for internal commands.
You can use the following events on UserInputEvents object to monitor
commands being activated and terminated: OnActivateCommand &
OnTerminateCommand.

Sanjay-
0 Likes
Message 3 of 3

Boorda
Advocate
Advocate

I know this post is pretty old but I wanted to add a more in depth example of what Sanjay what talking about.

  

         ABOVE your  Public Sub Activate(ByVal addInSiteObject As ....  sub in your add-in, add the following code:

    

          Private WithEvents m_UserInputEvents As Inventor.UserInputEvents

 

        IN your  Public Sub Activate(ByVal addInSiteObject As .... sub add the following code:

   

          m_UserInputEvents = oApp.CommandManager.UserInputEvents

        

    Then you will need to add some new subs to catch these events...

 

     #Region "Inventor Events"

 

               Public Sub InvOnActivateCommand(ByVal CommandName As String, _

               ByVal Context As Inventor.NameValueMap) Handles m_UserInputEvents.OnActivateCommand

                          'Your Code here....

               End Sub

 

               Public Sub InvOnTerminateCommand(ByVal CommandName As String, _

               ByVal Context As Inventor.NameValueMap) Handles m_UserInputEvents.OnTerminateCommand

                         'Your Code here....

               End Sub

 

      #End Region


Automation is key!
0 Likes