MindManager cannot find event api
Answered
I am currently developing a MindManager plugin, and my current requirement is that when opening a file, if the file name includes 'xxx', I want to automatically display a message box. However, I'm facing difficulties as I can't find the event for opening a file in the API. Please help me, and I am immensely grateful.
Hello
Events are described in the API documentation at https://www.mindmanager.com/en/pages/developers/api/22/#Welcome.html
There are three steps for handling an event in an Add-in.
The examples below are in VB but can be converted to another syntax.
1. Allocate an event object
Private WithEvents m__EventDocAdd As MM.Event = Nothing
It is important to use the "WithEvents" keyword to ensure that this object can raise events, otherwise nothing happens.
2. Configure the event object
If m__EventDocAdd Is Nothing Then
Try
i_Mask = MM.MmDocumentEventFlags.mmEventFlagDocumentAdded + MM.MmDocumentEventFlags.mmEventFlagDocumentOpened
m__EventDocAdd = m__MindManager.Events.AddDocumentEvent(i_Mask, False, True, Nothing) ' notify after adding
Catch o_Ex As Exception
ErrorFormShow(System.Reflection.MethodInfo.GetCurrentMethod.Name, String.Format("Mask {0}", i_Mask.ToString), o_Ex)
m__EventDocAdd = Nothing
End Try
End If
In the above code, "MM" is the MindManager Interop interface. i_Mask is a long integer. You can combine event flags. The event object configured above will fire when a new document is created, or when an existing document is opened.
3. Handle the event
Friend Sub p_EventDocAdd_Fire(ByVal eventFlag As Integer, ByVal time As MM.MmEventTime, ByVal pSource As Object, ByRef pExtra As Object) Handles m__EventDocAdd.Fire
The signature of the event handler must match otherwise a syntax error is thrown. The handler receives a flag to indicate whether the callback is occurring before or after the event, which applies to some of the events such as Save. It passes the relevant object as "pSource", which will need to be translated to the correct object type depending on the event. In this case, the object type is a Document.
If your requirements are fairly simple and could be handled with a macro instead of an Add-in, you could use App Studio for MindManager instead This allows you to connect a macro to an event without needing to access the MindManager API or writing an Add-in. Not all events are supported, but new document and document open events are.
Hello
Events are described in the API documentation at https://www.mindmanager.com/en/pages/developers/api/22/#Welcome.html
There are three steps for handling an event in an Add-in.
The examples below are in VB but can be converted to another syntax.
1. Allocate an event object
Private WithEvents m__EventDocAdd As MM.Event = Nothing
It is important to use the "WithEvents" keyword to ensure that this object can raise events, otherwise nothing happens.
2. Configure the event object
If m__EventDocAdd Is Nothing Then
Try
i_Mask = MM.MmDocumentEventFlags.mmEventFlagDocumentAdded + MM.MmDocumentEventFlags.mmEventFlagDocumentOpened
m__EventDocAdd = m__MindManager.Events.AddDocumentEvent(i_Mask, False, True, Nothing) ' notify after adding
Catch o_Ex As Exception
ErrorFormShow(System.Reflection.MethodInfo.GetCurrentMethod.Name, String.Format("Mask {0}", i_Mask.ToString), o_Ex)
m__EventDocAdd = Nothing
End Try
End If
In the above code, "MM" is the MindManager Interop interface. i_Mask is a long integer. You can combine event flags. The event object configured above will fire when a new document is created, or when an existing document is opened.
3. Handle the event
Friend Sub p_EventDocAdd_Fire(ByVal eventFlag As Integer, ByVal time As MM.MmEventTime, ByVal pSource As Object, ByRef pExtra As Object) Handles m__EventDocAdd.Fire
The signature of the event handler must match otherwise a syntax error is thrown. The handler receives a flag to indicate whether the callback is occurring before or after the event, which applies to some of the events such as Save. It passes the relevant object as "pSource", which will need to be translated to the correct object type depending on the event. In this case, the object type is a Document.
If your requirements are fairly simple and could be handled with a macro instead of an Add-in, you could use App Studio for MindManager instead This allows you to connect a macro to an event without needing to access the MindManager API or writing an Add-in. Not all events are supported, but new document and document open events are.
---