Page 1 of 1

Tooltip in a combo box?

Posted: Thu Oct 21, 2010 2:43 pm
by hag
I'd like to display a tooltip for each line of a combo box as the user scrolls down the list or puts mouse on the item a tooltip appears.
here is the structure of the combobox

Code: Select all

REDEFINE COMBOBOX OCBX1 VAR cPandl1 ITEMS { "         < Other Activity Items >",;
         "Amortization of prepaid expenses"                           ,;
         "Credit line financing and Interest expense"                 ,;
         "Due to from owners/affiliate and Interest owners"           ,;
         "Expense as a percent of change in net assets"               ,;
         "Interest on cash balances"                                  ,;    
         "Investment activity and Revenue From Investments"           ,;
         "Notes rec'able amortization and Interest income"            ,;
         "Sale of equipment and Gain or loss on the sale of assets"   ,;
         "Service contracts receivable and Service income"            ,;
         "Start up expenses"                                          ,;
         "Term loan amortization and Interest expense"                };
         ID 19 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl1,10,oDlg,nNewVar),mmcurrec := gl->(recno()),openfilter := .f.,;
         asetfilter(.f.,obrw),oDlg:show()                             ,;
         setcalc2(obrw,odlg,2)                                        ,;
         fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus())         ;
         UPDATE
 
Thanks in advance..

Re: Tooltip in a combo box?

Posted: Thu Oct 21, 2010 4:06 pm
by James Bott
Harvey,

Unfortunately, there is only one tooltip per control. Doing what you want would require major changes to the combobox class.

James

Re: Tooltip in a combo box?

Posted: Thu Oct 21, 2010 4:52 pm
by hag
Thanks James.

Re: Tooltip in a combo box?

Posted: Thu Oct 21, 2010 6:38 pm
by ukoenig
Harvey,

I added some Lines in ON CHANGE.
It shows different Tooltips in Relation to the selected Combobox-Row.

Image

REDEFINE COMBOBOX oCbx1 VAR cItem1 ITEMS { "One", "Two", "Three" } ;
ID ID_SIMPLE OF oDlg ;
ON CHANGE ( cItem4 := cItem1, oSay:Refresh(), ;
IIF( oCbx1:nAt = 1, oCbx1:oGet:cTooltip := "Tooltip Row-position 1", NIL ), ;
IIF( oCbx1:nAt = 2, oCbx1:oGet:cTooltip := "Tooltip Row-position 2", NIL ), ;
IIF( oCbx1:nAt = 3, oCbx1:oGet:cTooltip := "Tooltip Row-position 3", NIL ) ) ;

VALID ( cItem4 := cItem1, oSay:Refresh(), .t. )

It works, but maybe still something to include.
Maybe possible without selecting a Item ( using Mouse-Cursor-position )

Another Solution could be : showing a Message ( 2 Seconds ) on Row-change.

Image

REDEFINE COMBOBOX oCbx1 VAR cItem1 ITEMS { "One", "Two", "Three" } ;
ID ID_SIMPLE OF oDlg ;
ON CHANGE ( cItem4 := cItem1, oSay:Refresh(), ;
IIF( oCbx1:nAt = 1, MsgWait( "Message-Test 1", "Row Position 1", 2 ), NIL ), ;
IIF( oCbx1:nAt = 2, MsgWait( "Message-Test 2", "Row Position 2", 2 ), NIL ), ;
IIF( oCbx1:nAt = 3, MsgWait( "Message-Test 3", "Row Position 3", 2 ), NIL ) ) ;

VALID ( cItem4 := cItem1, oSay:Refresh(), .t. )

Best Regards
Uwe :)

Re: Tooltip in a combo box?

Posted: Thu Oct 21, 2010 10:23 pm
by hag
As usual you've been very helpful. The problem I have is on change a number of functions need to run. So I added the code you suggested it ran the functions as needed. Is there a way to put in the tool tip when the item is highlighted or moused over rather on change.

Re: Tooltip in a combo box?

Posted: Thu Jul 24, 2014 1:19 pm
by elvira
Hello,

I modified samples\testcomb.prg but I can´t get the tooltips.

Please, can you help me?

Code: Select all

// This sample shows how to create a Combo Test.

#include "FiveWin.ch"


//----------------------------------------------------------------------------//

function Main()

   local oDlg, oCbx, oSayItem, oSayAt
   local cItem := "this"

   SET _3DLOOK ON

   DEFINE DIALOg oDlg RESOURCE "TestCombo"

   REDEFINE COMBOBOX oCbx VAR cItem ITEMS { "Testing", "this", "ComboBox" } ;
      ID 110 OF oDlg ;
      ON CHANGE ( oCbx:oGet:cTooltip := "Elvira ", oCbx:ShowTooltip(), oSayItem:cTitle := cItem , ;
IIF( oCbx:nAt = 1, oCbx:oGet:cTooltip := "Tooltip Row-position 1", oCbx:oGet:cTooltip := "other" ), ;
IIF( oCbx:nAt = 2, oCbx:oGet:cTooltip := "Tooltip Row-position 2", NIL ), ;
IIF( oCbx:nAt = 3, MsgWait( "Message-Test 3", "Row Position 3", 2 ), NIL ) ) ;
VALID ( MsgBeep(), .t. )






/*
      ON CHANGE ( oSayItem:cTitle := cItem,;   // We should use also :SetText()
                  oSayAt:cTitle   := ":nAt = " + Str( oCbx:nAt, 2 ) ) ;
      VALID ( MsgBeep(), .t. )
*/


   REDEFINE SAY oSayItem ID 120 OF oDlg

   REDEFINE BUTTON ID 130 OF oDlg ACTION oCbx:Reset()

   REDEFINE BUTTON ID 140 OF oDlg ;
      ACTION oCbx:SetItems( { "Let's", "Set", "a new", "List" } )

   REDEFINE BUTTON ID 220 OF oDlg ACTION MsgInfo( Str( oCbx:nAt ) )

   REDEFINE SAY oSayAt ID 150 OF oDlg

   ACTIVATE DIALOG oDlg CENTERED ;
    on init oCbx:oGet:cTooltip := "Init tooltip"

return nil

//----------------------------------------------------------------------------//

Re: Tooltip in a combo box?

Posted: Sun Aug 10, 2014 10:49 am
by elvira
Up

Re: Tooltip in a combo box?

Posted: Wed May 31, 2017 9:43 pm
by vilian
+1

Re: Tooltip in a combo box?

Posted: Wed May 31, 2017 11:12 pm
by ariston.ap
Try this:

Code: Select all

oCbx:cToolTip := {|cTip|cTip:=oCbxToolTip(oCbx)}

//---------------------------------------------------------------------------//
FUNCTION oCbxToolTip(oCbx)
RETURN oCbx:GetText()
//----------------------------------------------------------------------------//
 

Re: Tooltip in a combo box?

Posted: Thu Jun 01, 2017 2:10 am
by vilian
Ariston,
Thank you for try help, but don't work. I want the same of Elvira wrote bellow:
hag wrote:As usual you've been very helpful. The problem I have is on change a number of functions need to run. So I added the code you suggested it ran the functions as needed. Is there a way to put in the tool tip when the item is highlighted or moused over rather on change.