.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Monitoring If the Text Edit Ribbon Tab Is Open

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
IvanShchitov
746 Views, 6 Replies

Monitoring If the Text Edit Ribbon Tab Is Open

Greetings,

 

How can I make a module that detects wether the text editing tab is open or not?

 

Best regards,

Ivan

Tags (2)
6 REPLIES 6
Message 2 of 7

You can track whenever the Tab is activated

 

For instance, from inside Initialize event

 

void IExtensionApplication.Initialize()
{
    Autodesk.Windows.RibbonControl ribCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
    foreach(Autodesk.Windows.RibbonTab tab in ribCtrl.Tabs )
    {
        if (!string.IsNullOrWhiteSpace(tab.Id) && tab.Id.Contains("ID_MText_Tab"))
        {
            tab.Activated += tab_Activated;
        }
    }

}

void tab_Activated(object sender, EventArgs e)
{
    // do something here...
}
Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 3 of 7

Thank you very much, Augusto!

Message 4 of 7

This code is for C++, isn't it? How to do the same in Visual Basic 2010?

Message 5 of 7

Actually is a C# code, and you can convert to VB.NET at http://www.developerfusion.com/tools/convert/csharp-to-vb/

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 6 of 7

Thank you, Augusto!

Message 7 of 7

Greetings, Augusto!

 

I've inserted your code in Microsoft Visual C# 2010 Express and it showed me three errors, particularly: 

 

01. 'CSharp_Plugin.DetectingTab.IExtensionApplication.Initialize()': containing type does not implement interface 'Autodesk.AutoCAD.Runtime.IExtensionApplication'

02. The type or namespace name 'Windows' does not exist in the namespace 'Autodesk' (are you missing an assembly reference?)

03. The type or namespace name 'Ribbon' does not exist in the namespace 'Autodesk.AutoCAD' (are you missing an assembly reference?)

 

How can I fix these errors?

 

Best regards,

Ivan

 

using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

namespace CSharp_Plugin
{
    public class DetectingTab
    {
        void IExtensionApplication.Initialize()
        {
            Autodesk.Windows.RibbonControl ribCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
            foreach (Autodesk.Windows.RibbonTab tab in ribCtrl.Tabs)
            {
                if (!string.IsNullOrWhiteSpace(tab.Id) && tab.Id.Contains("ID_MText_Tab"))
                {
                    tab.Activated += tab_Activated;
                }
            }

        }

        void tab_Activated(object sender, EventArgs e)
        {
            // do something here...
        }
    }
}

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost