close active tabpage

Discussion about CodeLite development process and patches
vsfai
CodeLite Enthusiast
Posts: 11
Joined: Tue Jan 10, 2012 11:50 pm
Genuine User: Yes
IDE Question: c++
Contact:

close active tabpage

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: close active tabpage

Post 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
Make sure you have read the HOW TO POST thread
vsfai
CodeLite Enthusiast
Posts: 11
Joined: Tue Jan 10, 2012 11:50 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: close active tabpage

Post 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);
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: close active tabpage

Post by eranif »

vsfai wrote:thank you, works well
No problem.

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

Eran
Make sure you have read the HOW TO POST thread
Post Reply