... 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?
Changing GadgetToolTip() text
Changing GadgetToolTip() text
MacBook Pro-M1 (2021), Tahoe 26.2, PB 6.30b6
Re: Changing GadgetToolTip() text
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
Last edited by Danilo on Fri Sep 12, 2014 5:37 am, edited 2 times in total.
Re: Changing GadgetToolTip() text
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 withbut 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.
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)Now I have to decide which way to go... either update the tooltip before changing the text or after changing the text.
MacBook Pro-M1 (2021), Tahoe 26.2, PB 6.30b6
Re: Changing GadgetToolTip() text
You can update the tooltip any time. Directly after creating the gadgets and after SetGadgetText() etc.WilliamL wrote:This doesn't give you the tooltip info update till you enter/change some text
Just call the function directly:
Code: Select all
GenerateStringGadgetTooltip( stringGadget )Re: Changing GadgetToolTip() text
Hi Danilo,
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.
That's what I did! It gets accessed from three locations and, since it is rather large, it is much more efficient that way.GenerateStringGadgetTooltip( stringGadget )
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.
MacBook Pro-M1 (2021), Tahoe 26.2, PB 6.30b6
