How to place a balloon tip (sprite?) on a GUI?

BlitzMax Forums/BlitzMax Beginners Area/How to place a balloon tip (sprite?) on a GUI?

Marco A G Pinto(Posted 2012) [#1]
Hello!!!

How do I make this image to appear when one tries to type non numeric characters in text boxes which only accept numbers?



Thanks!

Kind regards,
>Marco A.G.Pinto
--------------------


matibee(Posted 2012) [#2]
You probably can't without digging into Windows-only specifics. A simpler solution would be to set a gadget filter function that only allows numbers in..

SetGadgetFilter yourLineGadget, Filter_Integer

Function Filter_Integer(event:TEvent,context:Object)
	If event.ID=EVENT_KEYCHAR
		If event.data=KEY_BACKSPACE Return 1
		If event.data<48 Or event.data>57 Return 0
	EndIf
	Return 1
EndFunction


Disclaimer/credit where it's due: That filter function comes from JoshK's property grid which can be found in the code archives.


Marco A G Pinto(Posted 2012) [#3]
@matibee

Thanks for your help!

A quick question: I have improved the code in order to limit the number of digits in the text boxes.

But, if I have the contents highlighted with the maximum number of digits I have limited, it won't erase the digits and insert the pressed one.

Is there a command to check if the text boxes are highlighted?

' Filter the context of LIVES1 text box
' V1.0 - 15/MAR/2012
Function status_text_field_lives1_Filter_Integer(event:TEvent,context:Object)
	If event.ID=EVENT_KEYCHAR
		If event.data=KEY_BACKSPACE Return 1
		If event.data<48 Or event.data>57
			PlaySound beep
			Return 0
		EndIf
		If Len(GadgetText(status_text_field_lives1))=3
			PlaySound beep
			Return 0
		EndIf
	EndIf
	Return 1
End Function


Thanks!

Kind regards,
>Marco A.G.Pinto
--------------------


Zeke(Posted 2012) [#4]
limit textfield text:
SendMessageW QueryGadget(textfield,QUERY_HWND),EM_SETLIMITTEXT,3,0 '3=max characters


but you can still paste text to textfield. but here is working example:


also here is function to set textfield digits only (so no need gadgetfilter):
Function SetTextFieldDigitsOnly(gadget:TGadget)
	Local dwStyle:Int=GetWindowLongW(QueryGadget(gadget,QUERY_HWND),GWL_STYLE)
	SetWindowLongW(QueryGadget(gadget,QUERY_HWND),GWL_STYLE,dwStyle|ES_NUMBER)
End Function


Last edited 2012