Author Topic: Disable CC calltip when context Menu is opened(Same as ValueTooltip in GDB)  (Read 13063 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Hi, all.

In revision 5612, the debuggergdb plugin, OnValueTooltip() will be disabled when a context menu is open.

Code

void DebuggerGDB::OnValueTooltip(CodeBlocksEvent& event){

...
    if(ed->IsContextMenuOpened())
    {
     return;
    }
...


I think this can also  be applied to code Completion plugin

void CodeCompletion::OnValueTooltip(CodeBlocksEvent& event)


By ollydbg at 2009-06-16

Any comments?
A convinent way is that when a context menu is open, the editor stop sending Tooltip event.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
ollydbg,
I am not sure of the best solution, but the problem is very annoying. If there are several Code Completion options, they completely cover the Thread Search options on the context menu. Windows XP, SVN 5650.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
ollydbg,
I am not sure of the best solution, but the problem is very annoying. If there are several Code Completion options, they completely cover the Thread Search options on the context menu. Windows XP, SVN 5650.

Hi, rhf.

Did you mean that the Code Completion tooltip window cover "Thread Search Panel" ?

Where can I find "Thread Search options on the context menu"..Did you mean the "find the occurrence of "XXXXX" in the context menu?

I'm not quite full understand. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Any comments?
I've tested this and it works (and makes sense) IMHO. I have put it on my list of changes to CC.

I've done it as follows (shown is just the appropriate code snippet in void CodeCompletion::OnValueTooltip(CodeBlocksEvent& event) as I cannot provide a patch easily):
OLD:
Code
        EditorBase* base = event.GetEditor();
        cbEditor* ed = base && base->IsBuiltinEditor() ? static_cast<cbEditor*>(base) : 0;
        if (!ed)
            return;

        if (ed->GetControl()->CallTipActive())
            ed->GetControl()->CallTipCancel();
NEW:
Code
        EditorBase* base = event.GetEditor();
        cbEditor* ed = base && base->IsBuiltinEditor() ? static_cast<cbEditor*>(base) : 0;
        if (!ed || ed->IsContextMenuOpened())
            return;

        if (ed->GetControl()->CallTipActive())
            ed->GetControl()->CallTipCancel();
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I'm thinking that we can disable on cbEditor class

Code
void cbEditor::OnEditorDwellStart(wxScintillaEvent& event)
{
    cbStyledTextCtrl* control = GetControl();
    int pos = control->PositionFromPoint(wxPoint(event.GetX(), event.GetY()));
    int style = control->GetStyleAt(pos);
    NotifyPlugins(cbEVT_EDITOR_TOOLTIP, style, wxEmptyString, event.GetX(), event.GetY());
    OnScintillaEvent(event);
}

When Dwell starts, we should first check

IsContextMenuOpened()

Am I right?

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I tested, and these code works fine. :D

Code
void cbEditor::OnEditorDwellStart(wxScintillaEvent& event)
{
    cbStyledTextCtrl* control = GetControl();
    int pos = control->PositionFromPoint(wxPoint(event.GetX(), event.GetY()));
    int style = control->GetStyleAt(pos);
    if(IsContextMenuOpened()==false)
        NotifyPlugins(cbEVT_EDITOR_TOOLTIP, style, wxEmptyString, event.GetX(), event.GetY());
    OnScintillaEvent(event);
}


Any comments?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Don't do == false, but use ! :-) This is not C#  :lol:
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Are you aware, that we use exactly the same code in debuggergdb.cpp and codecompletion.cpp OnValueTooltip():
Code
    if(ed->GetControl()->CallTipActive())
    {
     ed->GetControl()->CallTipCancel();
    }

That means the it's not clear which function wins and supresses the other.
« Last Edit: June 18, 2009, 02:34:44 pm by jens »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Are you aware, that we use exactly the same code in debuggergdb.cpp and codecompletion.cpp OnValueTooltip():
Code
    if(ed->GetControl()->CallTipActive())
    {
     ed->GetControl()->CallTipCancel();
    }

That means the it's not clear which function wins and supresses t

Oh, Yes, When I'm debugging, there is only "tip" from debuggergdb.
Seems the "tip" from code completion always be canceled. :D


@oBFusCATed
Thanks for the hint.  :D


Edit:
Code
	// get rid of other calltips (if any) [for example the code completion one, at this time we
// want the debugger value call/tool-tip to win and be shown]
    if(ed->GetControl()->CallTipActive())
    {
    ed->GetControl()->CallTipCancel();
    }

This code in debuggergdb was added in r5614.

I think we should find another way to disable CC's tip when debugging.
« Last Edit: June 18, 2009, 02:37:01 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Oh, Yes, When I'm debugging, there is only "tip" from debuggergdb.
Seems the "tip" from code completion always be canceled. :D

That's because debugger needs more time before the tooltip is called (sending commands to gdb, waiting for response, parsing output...), so it can cancel the other one.

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Did you mean the "find the occurrence of "XXXXX" in the context menu?
Yes. Just as in your original post on this topic, if your BeginLoadingProject() had several overloads, the Code Completion tool tip can mask the options: "Find declaration of: ...", "Find implementation of: ...", "Find occurrences of:  ...", etc.
Thanks for pursuing this.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
@rhf
You are welcome :D
@jens
I think debuggergdb plugin should temporary disable other plugins event sink for Tooltips. It is not easy to implement.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Or there should be cbEditor->EmitTooltip(something) that is used by all of the folks that show tooltips.
So if there are two tooltips shown simultaneously it can merge them or show only the last emitted tooltip.
But, I'm no sure if that is possible... :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Or there should be cbEditor->EmitTooltip(something) that is used by all of the folks that show tooltips.
So if there are two tooltips shown simultaneously it can merge them or show only the last emitted tooltip.
But, I'm no sure if that is possible... :(
show only the last emitted tooltip is not the reliable way, because as jens said, we are not sure which plugin receive this kind of event first, and which plugin call the ed->showtip first.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
If you could find a way to force the tooltips to always display "above" the selection, as happens now when the selection is at the bottom of the editor screen, then most (all?) of the overlap problems would go away. Just a suggestion.