Highlighted

Event for switching document tabs.

New Here ,
Jan 17, 2016

Copy link to clipboard

Copied

Hi everybody,

Currently, i am working on events of document.

Now, i am seeking for an event that cotrols the action switch among the opened documents on workstation.

Does anyone know about this kind of event?

Thanks.

Duy

Hi Duy,

do you want to get a notification when the user changes the current document?

If yes, then you can attach an observer to the ISubject interface of the session boss to observe for the protocol id IID_IACTIVECONTEXT. In the Update function of your observer you get this id as the protocol parameter and a point to an instance of IActionContext::ContextInfo as the changeBy parameter which is a key value pair. If the key is IID_IDOCUMENT then the active document has changed and the value is a pointer to the IActiveContext of the old context. You can get the IActiveContext of the new context via the subject parameter of the Update function. On each IActiveContext instance you can call the GetContextDocument function.

Markus

TOPICS
SDK

Views

397

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Event for switching document tabs.

New Here ,
Jan 17, 2016

Copy link to clipboard

Copied

Hi everybody,

Currently, i am working on events of document.

Now, i am seeking for an event that cotrols the action switch among the opened documents on workstation.

Does anyone know about this kind of event?

Thanks.

Duy

Hi Duy,

do you want to get a notification when the user changes the current document?

If yes, then you can attach an observer to the ISubject interface of the session boss to observe for the protocol id IID_IACTIVECONTEXT. In the Update function of your observer you get this id as the protocol parameter and a point to an instance of IActionContext::ContextInfo as the changeBy parameter which is a key value pair. If the key is IID_IDOCUMENT then the active document has changed and the value is a pointer to the IActiveContext of the old context. You can get the IActiveContext of the new context via the subject parameter of the Update function. On each IActiveContext instance you can call the GetContextDocument function.

Markus

TOPICS
SDK

Views

398

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 17, 2016 0
Enthusiast ,
Jan 18, 2016

Copy link to clipboard

Copied

Hi Duy,

do you want to get a notification when the user changes the current document?

If yes, then you can attach an observer to the ISubject interface of the session boss to observe for the protocol id IID_IACTIVECONTEXT. In the Update function of your observer you get this id as the protocol parameter and a point to an instance of IActionContext::ContextInfo as the changeBy parameter which is a key value pair. If the key is IID_IDOCUMENT then the active document has changed and the value is a pointer to the IActiveContext of the old context. You can get the IActiveContext of the new context via the subject parameter of the Update function. On each IActiveContext instance you can call the GetContextDocument function.

Markus

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 18, 2016 0
New Here ,
Jan 18, 2016

Copy link to clipboard

Copied

Hi Markus,

Yes, It's exactly what i want to ask.

Thanks for the suggestion.

But i met an issues,

I implemented as your comment but the update function is called many times depend on the number of opened pages.

My below code will show the alert message  3 times if i open 3 documents and switch among these pages.

Can you tell me did i miss something?

// Protocols used for page item model changes

IActiveContext *context = GetExecutionContextSession()->GetActiveContext();

if (context)

{

InterfacePtr<ISubject> contextSubject(context, UseDefaultIID());
if (contextSubject && !contextSubject->IsAttached(ISubject::kRegularAttachment, this, IID_IACTIVECONTEXT, IID_INISUIDOCUMENTOBSERVER))
     contextSubject->AttachObserver(ISubject::kRegularAttachment, this, IID_IACTIVECONTEXT, IID_INISUIDOCUMENTOBSERVER);

}

IActiveContext::ContextInfo* contextInfo = reinterpret_cast<IActiveContext::ContextInfo*>(changedBy);
if (contextInfo->Key() == IID_IDOCUMENT)
{
    CAlert::InformationAlert("Switching pages");
}

Thanks

Duy

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 18, 2016 0
Enthusiast ,
Jan 18, 2016

Copy link to clipboard

Copied

Hi Duy,

did you open 3 documents? Then it is correct that the Update function is called 3 times.

Or did you open 1 document with 3 pages? Then you can check if the documents from the old IActiveContext and the new IActiveContext are the same.

Markus

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 18, 2016 0
New Here ,
Jan 19, 2016

Copy link to clipboard

Copied

Hi Markus,


Thanks for your response

I opened 3 documents, and switch among these documents,

Sorry for making confusing.

How can i control this function that my alert message is only shown one time.

Because i only need to catch event active document changes.

I follow LinkWatcher project on sdksample folder.

The code in this project is same with mine but i don't know why it's only update one time


Duy

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2016 0
Enthusiast ,
Jan 19, 2016

Copy link to clipboard

Copied

Hi Duy,

the LinkWatcher project caches the current document in fCurrentDocument and handles the change only if the document from IActiveContext is not the same.

Markus

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2016 0
New Here ,
Sep 24, 2020

Copy link to clipboard

Copied

Hi Markus

That's the solution which I was searching. but I could not figure out how to implament it. Can you explain exactly how to do it?

Thanks

Mustafa

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2020 0