Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

how to forbid a refresh when a tree item get double clicked

(1/3) > >>

ollydbg:
Hi, I found an issue( In fact, I have reported in http://forums.codeblocks.org/index.php/topic,9873.msg69760.html#msg69760, but nobody give any response :(. This is really an annoying issue!)

When I double click on a tree item in the CodeCompletion's classbrowser, then the tree control will get refreshed, meanwhile the scroll bar will go down to the bottom of the window.



I found this behavior comes from these code:


--- Code: ---void ClassBrowser::OnTreeItemDoubleClick(wxTreeEvent& event)
{
    wxTreeCtrl* tree = (wxTreeCtrl*)event.GetEventObject();
wxTreeItemId id = event.GetItem();
CBTreeData* ctd = (CBTreeData*)tree->GetItemData(id);
    if (ctd && ctd->m_pToken)
    {
        if (wxGetKeyState(WXK_CONTROL) && wxGetKeyState(WXK_SHIFT))
        {
            CCDebugInfo info(tree, m_pParser, ctd->m_pToken);
            info.ShowModal();
            return;
        }

        cbProject* prj = Manager::Get()->GetProjectManager()->GetActiveProject();
        if (prj)
        {
bool toImp = false;
switch (ctd->m_pToken->m_TokenKind)
{
case tkConstructor:
            case tkDestructor:
            case tkFunction:
                if (ctd->m_pToken->m_ImplLine != 0 && !ctd->m_pToken->GetImplFilename().IsEmpty())
                    toImp = true;
break;
default:
break;
}

            wxString base = prj->GetBasePath();
            wxFileName fname;
            if (toImp)
                fname.Assign(ctd->m_pToken->GetImplFilename());
            else
                fname.Assign(ctd->m_pToken->GetFilename());

            NormalizePath(fname, base);
         cbEditor* ed = Manager::Get()->GetEditorManager()->Open(fname.GetFullPath());
if (ed)
{
int line;
                if (toImp)
                    line = ctd->m_pToken->m_ImplLine - 1;
                else
                    line = ctd->m_pToken->m_Line - 1;
ed->GotoLine(line);
// // try to move the caret on the exact token
// int lineOffset = ed->GetControl()->GetCurLine().Find(ctd->m_pToken->m_Name);
// if (lineOffset != wxNOT_FOUND)
// {
//                    int pos = ed->GetControl()->PositionFromLine(line) + lineOffset;
//                    ed->GetControl()->GotoPos(pos);
//                    // select the token
//                    int posend = ed->GetControl()->WordEndPosition(pos, true);
//                    ed->GetControl()->SetSelection(pos, posend);
// }

wxFocusEvent ev(wxEVT_SET_FOCUS);
ev.SetWindow(this);
#if wxCHECK_VERSION(2, 9, 0)
ed->GetControl()->GetEventHandler()->AddPendingEvent(ev);
#else
ed->GetControl()->AddPendingEvent(ev);
#endif
}
        }
    }
}

--- End code ---


Since after running this function, the whole panel will get refreshed, then UpdateView() will be called.

In UpdateView(), precisely in the function void ClassBrowser::BuildTree(), the "treeMembers" TreeCtrl will be rebuild from a ClassBrowserBuilderThread.

Then after the tree was reconstructed, the Scroll bar will slip down to the bottom of that window.

So, my suggestion is:

If I can forbid a refresh event after doubleclick, the "treemembers" TreeCtrl would keep its position.

Or, we can supply a separate handler, because currently, both treeAll and treemembers share this handler.


--- Code: --- EVT_TREE_ITEM_ACTIVATED(XRCID("treeMembers"), ClassBrowser::OnTreeItemDoubleClick)


EVT_TREE_ITEM_ACTIVATED(XRCID("treeAll"), ClassBrowser::OnTreeItemDoubleClick)        

--- End code ---

Any comments?

Thanks.

MortenMacFly:

--- Quote from: ollydbg on June 14, 2009, 06:49:25 pm ---Or, we can supply a separate handler, because currently, both treeAll and treemembers share this handler.
Any comments?

--- End quote ---
This sounds most convenient to me. :-)

Jenna:
This does only happen, if the view is "Current files's symbols".

And what's more, if I see it right, it does not happen in new CC, what's currently in testing phase.

ollydbg:
thanks for alll the replies!


--- Quote from: jens on June 14, 2009, 09:01:45 pm ---This does only happen, if the view is "Current files's symbols".
--- End quote ---

Yes, seems it only affects the "current files's symbols"

--- Quote ---And what's more, if I see it right, it does not happen in new CC, what's currently in testing phase.
--- End quote ---

I have just download and build the AUI_branch(windows MinGW), but I found this issue still happens there. :(





Jenna:

--- Quote from: ollydbg on June 15, 2009, 04:11:49 am ---I have just download and build the AUI_branch(windows MinGW), but I found this issue still happens there. :(

--- End quote ---

That's because the new CC-code is not (yet) in any branch.

By the way, the issue only appears (at least for me), if the double-clicked token is in another file (normally the header or source file with the same basename).

Navigation

[0] Message Index

[#] Next page

Go to full version