Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Patch add event for editor split and unsplit
arthurzmj:
I've create a ticket on https://sourceforge.net/p/codeblocks/tickets/2/
I think it's useful sometimes.
Declare here for developer's attention.
oBFusCATed:
Examples?
You've mentioned the KeyBinder plugin, but I don't see changes in it.
arthurzmj:
--- Quote from: oBFusCATed on May 23, 2014, 11:55:44 pm ---Examples?
You've mentioned the KeyBinder plugin, but I don't see changes in it.
--- End quote ---
I found such codes in KeyBinder
--- Code: ---// ----------------------------------------------------------------------------
void cbKeyBinder::OnWindowCreateEvent(wxEvent& event)
// ----------------------------------------------------------------------------
{
// wxEVT_CREATE entry
// Have to do this for split windows since CodeBlocks does not have
// events when opening/closing split windows
// Attach a split window (or any other window)
if ( m_bBound )
{
wxWindow* pWindow = (wxWindow*)(event.GetEventObject());
cbEditor* ed = 0;
//cbStyledTextCtrl* p_cbStyledTextCtrl = 0;
//cbStyledTextCtrl* pLeftSplitWin = 0;
cbStyledTextCtrl* pRightSplitWin = 0;
ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (ed)
{ //p_cbStyledTextCtrl = ed->GetControl();
//pLeftSplitWin = ed->GetLeftSplitViewControl();
pRightSplitWin = ed->GetRightSplitViewControl();
//Has this window been split?
//**This is a temporary hack until some cbEvents are defined**
if ( pWindow && (pRightSplitWin == 0) )
{
//-if (pRightSplitWin eq pWindow)
//-{ Attach(pRightSplitWin);
if (pWindow->GetParent() == ed)
{ LOGIT( _T("OnWindowCreateEvent Attaching:%p"), pWindow );
AttachEditor(pWindow);
}
}
}
}//if m_bBound...
event.Skip();
}//OnWindowCreateEvent
--- End code ---
Although The plugin can find the split window in such way, the window relationship has not been built yet in such event.
That means the plugin can not find this window by Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor()->GetRightSplitViewControl()
What's more, the window's parent is going to be changed to a wxSplitterWindow after the window was created. In my cbVike plugin, It's important to get this wxSplitterWindow, but there is no way to do this without the split and unsplit event. You can refer to https://github.com/zmj64351508/cbvike . It's very similar to keyBinder in structure.
Edit: Another example is if the plugin want to do something like change the caret style in WindowCreateEvent, it may crash the app because the wxScintilla is not initialized when this event occurs.
oBFusCATed:
Are you willing to provide a patch for keybinder, too?
arthurzmj:
OK. But the patch for keyBinder may come a few days later since I'm a little busy this week.
Navigation
[0] Message Index
[#] Next page
Go to full version