Page 1 of 1

close active tabpage

Posted: Wed Jan 11, 2012 12:10 am
by vsfai
Hello,

I have problem how can i close active or selected tabpage in CL editor.

In my plugin i am using for add new page this: m_mgr->AddEditorPage(.....);

Now i need by right click mouse button close it, but i dont know how can i get the name for active page...

This is working:
//wxString projectName = m_mgr->GetWorkspace()->GetActiveProjectName();
//wxString closePage = wxT(projectName); - tabpage is created with the same name like active project.
//m_mgr->ClosePage(closePage); - the tabpage is correctly closed.

How can i close it without this know this name? Can i close active page, which is selected in the CL editor?
I need something like this: m_mgr->ClosePage(m_mgr->GetActivePage()->GetName());
thx.

vsfai.

Re: close active tabpage

Posted: Wed Jan 11, 2012 12:17 pm
by eranif
You can achieve this by simply sending an event to the main frame let it know that you want to close the active tab

Code: Select all

wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("close_file"));
wxTheApp->GetTopWindow()->GetEventHandler()->AddPendingEvent(evt);
Eran

Re: close active tabpage

Posted: Wed Jan 11, 2012 8:24 pm
by vsfai
thank you, works well ;)

#include <wx/xrc/xmlres.h>
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("close_file"));
m_mgr->GetTheApp()->GetTopWindow()->GetEventHandler()->AddPendingEvent(evt);

Re: close active tabpage

Posted: Wed Jan 11, 2012 9:01 pm
by eranif
vsfai wrote:thank you, works well
No problem.

FYI: using this approach, you can emulate every menu item from your plugin

Eran