Page 1 of 1
Changing GadgetToolTip() text
Posted: Thu Sep 11, 2014 7:43 pm
by WilliamL
... a program is never done.
Each day, of my monthly budget program, is made up of 6 string fields that hold info (like date,description,code,amnt,etc) and depending on the information entered there could be different GadgetToolTip() information that I would like to display when the cursor is hovering over the field.
What I'd like to do is get the gadget number and send it to a procedure that would fill in the appropriate text to the GadgetToolTip() to be displayed.
This sounds like a nice idea but I don't know if it is possible or if it would be too complicated to be worth the effort.
Any ideas?
Re: Changing GadgetToolTip() text
Posted: Thu Sep 11, 2014 8:13 pm
by Danilo
You could re-generate the Tooltip when the StringGadget content changed.
Code: Select all
Procedure GenerateStringGadgetTooltip( stringGadget )
tt.s = "Text length: "+Str( Len(GetGadgetText(stringGadget)) )
GadgetToolTip(stringGadget, tt)
EndProcedure
Procedure OnStringGadgetChanged()
GenerateStringGadgetTooltip( EventGadget() )
EndProcedure
If OpenWindow(0, 0, 0, 322, 170, "StringGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
For i = 0 To 5
StringGadget(i, 8, 10+i*25, 306, 20, "")
BindGadgetEvent(i,@OnStringGadgetChanged(),#PB_EventType_Change)
GenerateStringGadgetTooltip( i )
Next
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Changing GadgetToolTip() text
Posted: Thu Sep 11, 2014 9:18 pm
by WilliamL
Danilo, very nice!
Simple, clever, and works fine. This doesn't give you the tooltip info update till you enter/change some text but the tooltip doesn't have to be processed every time you go to the gadget and the info is there every time you go back to the gadget. I guess I was looking for something more like #PB_EventType_Focus but I wonder if maybe doing it your way might be better.
I like your idea and will try it for now. This was definitely not too difficult!
[later]
I tried it with
Code: Select all
StringGadget(5, 8, 140, 306, 20, "") : BindGadgetEvent(5,@OnStringGadgetChanged(),#PB_EventType_Focus)
but it seems that it doesn't display most of the time. Dunno why. No scratch that, it seems to work fine if the field is selected which is a limitation.
Now I have to decide which way to go... either update the tooltip before changing the text or after changing the text.
Re: Changing GadgetToolTip() text
Posted: Fri Sep 12, 2014 5:26 am
by Danilo
WilliamL wrote:This doesn't give you the tooltip info update till you enter/change some text
You can update the tooltip any time. Directly after creating the gadgets and after SetGadgetText() etc.
Just call the function directly:
Code: Select all
GenerateStringGadgetTooltip( stringGadget )
Example above updated.

Re: Changing GadgetToolTip() text
Posted: Fri Sep 12, 2014 4:59 pm
by WilliamL
Hi Danilo,
GenerateStringGadgetTooltip( stringGadget )
That's what I did! It gets accessed from three locations and, since it is rather large, it is much more efficient that way.
Hey, it's nice to learn something new! I finally see how BindGadgetEvents work and what it can be used for. Nothing like having a coding need and learning something new as a result.
Thanks for your help.