Using CallTips

Topics: Developer Forum
Feb 13, 2008 at 12:49 PM
Hi Chris,

how can i use calltips? i'm using your latest version of Nov 7.
unfortunately i'm not able to find any information for using calltips, like how to fire the calltipclick event and so on.

can you post some short lines to give me a hint? that would be very nice.

best regards
kojak
Coordinator
Feb 15, 2008 at 2:37 AM
Edited Feb 15, 2008 at 2:48 AM
First be sure and get the latest version. It seems like a missed some important things when I was doing the CallTip code. Oh and "hide property" should be "Hide() method", D'oh!

// Example #1
// This is the simplest way to use a calltip
// it will display at the current document
// position
scintilla1.CallTip.Show("Simple message");

// Example #2
// This overload one lets you set where the
// calltip is displayed (by document position)
// In this case it will always show right below
// the first document character, even if it's
// scrolled out of view
scintilla1.CallTip.Show("Simple message", 0);

// Example #3
// If you want to use the Calltips as a function
// overload list a la SCite or Visual Studio the
// easiest way it to use the ShowOverload method
// It takes care of handling the arrow clicks
// for you
string[] overloads = new string[]
{
"void CallTip.ShowOverload(int position)",
"void CallTip.ShowOverload(OverloadList overloadList)",
"void CallTip.ShowOverload(uint startIndex)",
"void CallTip.ShowOverload(int highlightStart, int highlightEnd)",
"void CallTip.ShowOverload(int position, uint startIndex)"
};

// One of OverloadList's constructors takes any IEnumerable<string>
OverloadList ol = new OverloadList(overloads);
scintilla1.CallTip.ShowOverload(ol);


// Example #4
// This shows how you can do your own arrow handling logic.

// Have to listen for the events
scintilla1.CallTipClick += new EventHandler<CallTipClickEventArgs>(scintilla1_CallTipClick);

// Note that \u0001 is the up arrow and \u0002 is the down
// arrow placeholders, you can also use constants
// CallTip.UpArrow and CallTip.DownArrow
scintilla1.CallTip.Show("Testing \u0001 arrows \u0002");
...
private void scintilla1_CallTipClick(object sender, CallTipClickEventArgs e)
{
// You should always hide the calltip before reshowing it or
// unpredictable things might start happening
scintilla1.CallTip.Hide();

if(e.CallTipArrow == CallTipArrow.Up)
scintilla1.CallTip.Show("Testing \u0001 arrows \u0002 (up arrow clicked)");
else if(e.CallTipArrow == CallTipArrow.Down)
scintilla1.CallTip.Show("Testing \u0001 arrows \u0002 (down arrow clicked)");
else
scintilla1.CallTip.Show("Testing \u0001 arrows \u0002");
}
Feb 15, 2008 at 11:10 AM
Hi Chris,

thank you for your information. The examples helped me a lot.
But i now have a problem in displaying the up and down arrows. The symbol for '\uuu1' and '\0002' won' t be displayed. There is even no square which you normally get if a symbol is not able to be displayed. If i set another value like '\uuu3' i will get the square.
Do u use a special font? Do u have any ideas?

Best regards
kojak
Coordinator
Feb 15, 2008 at 4:26 PM
Nope, I just looked at the Scintilla code, it's drawing the arrows manually, not by using a font. I don't suppose you're trying this in VB.NET or some other language that doesn't have string literal codes like c#? If this is the case you have to either use their equivalent syntax or:

String.Concat("Testing ", CallTipArrow.Up, " arrows ", CallTipArrow.Down)