How to show tooltips in Symbian applications
Article Metadata
A Tooltip is a small rectangular dialog that comes up as a help/description when you pause over a partucular control. It can either stay or dismiss in sometime.
Derive a container from CCoeControl, and in its ConstructL set the size of the rectangle of the tooltip along with the position where you want to show the tooltip.
iText->SetExtent(TPoint( 15, 15 ),iText->MinimumSize() );
iText here is a RichTextEditor.
void CTooltipContainer::Draw( const TRect& aRect ) const
{
///Make a Tooltip like rectangle
TRect iRect;
iRect = aRect;
iRect.Shrink(10,10);
CWindowGc& gc = SystemGc();
gc.SetPenColor(KRgbBlack);
gc.SetBrushColor( TLogicalRgb( TRgb(254,255,213) ) );
gc.Clear(iRect);
gc.DrawRect(iRect);
gc.SetClippingRect(iRect);
}
This tooltip can be shown depending upon a HandleKeyEventL/HandleCommandL or use a Timer to detect pause on a control and then show the tooltip.
A good tooltip example is the Active Standby screen of S60 2nd ED FP3 onwards devices, where the active standby apps display a tooltip of the app name.
The code above is simple and works as long as you always draw the tooltip topmost in the controller. You can create a floating tooltip by using a separate window, removing the coupling, see http://mikie.iki.fi/symbian/textbox.html .


(no comments yet)