CreateHyperLink suggested changes

BlitzMax Forums/MaxGUI Module/CreateHyperLink suggested changes

degac(Posted 2008) [#1]
I just noticed this aspect of CreateHyperLink (taken from the help page...)

The optional customtext$ parameter allows you to set friendly text that is displayed instead of the URL in the label. If this is set then the label's tooltip is automatically generated with the URL the link refers to. Although this masking text can be changed at any time by calling SetGadgetText, the url$ that the hyperlink gadget opens cannot be altered once the gadget has been created.



As I don't like the last sentence (and I want to be free to change the URL without destroying and recreate a new gadget) I suggest this little change to the CreateHyperLink() code
	Method SetText(_url$) 
		url = _url
		Super.settext(_url) 
	End Method

	Method SetToolTip(_url$) 
		proxy.settooltip(_url) 
	End Method


This will allow to change the URL via a SetGadgetText command. The tooltip (if any) must be defined with SetGadgetToolTip()



I think in this way the HyperLink gadget is more usable

ps: wow! I just noticed there is a new CreateSplitter gadget!


degac(Posted 2008) [#2]
I just noticed that my suggested changes have a negative impact as you can not more use the 'alternate text' (if any).
So there is a complete rewrite of HyperLink.bmx


With SetGadgetText() it is possibile to change ONLY the URL, the AlternateText still remain. (Unless we use SetGadgetToolTip to change both ToolTip and alternate_text...)

edit:

I'm playing with SetGadgetExtra(gadget,object). At the moment I can change everything (URL, tooltip, label) with standard MaxGUI commands.

edit2:

A third - not conventional & strange - method I tested

	Method SetText(_url$) 
		
		If _URL.find("||")<0
	             	url = _url
		        If String(Self.extra)<>"" Super.settext(String(Self.extra) ) 
		Else
		        Local turl$[2]
			turl= _url.split("||") 
			If turl[1] <> "" Super.settext turl[1]
			url=turl[0]
	        End If
	
	End Method


SetGadgetText hypCenter,"www.graphio.net||To my site"

If there is not "||" SetGadgetText changes the only the URL, else the string is splitted in two parts: the URL and the new Label/Text.


SebHoll(Posted 2008) [#3]
I just noticed that my suggested changes have a negative impact as you can not more use the 'alternate text' (if any).

Exactly the reason why I implemented that behaviour.

I like the SetGadgetExtra() idea though... I'll take a look at some point, but I think I might keep the current behaviour 'as is' (with SetGadgetText() affecting the displayed text), and use SetGadgetExtra() to set the URL.

Sounds fair enough?


degac(Posted 2008) [#4]
Perfect.
What is important it's a way to allow the user to change the URL.


SebHoll(Posted 2008) [#5]
I've just committed a new version (rev. 84).

You should now be able to set the URL using SetGadgetExtra() and retrieve it using String( GadgetExtra() ).

Let me know if this is OK...


degac(Posted 2008) [#6]
Great. It works perfectly.
Thanks.

ps: semi-related problem

I've tested on MacOS X (PPC - 10.3.9) the old and the new version of CreateHyperLink() gadget, and I get the same problem: OpenURL doesn't open the brower (the default one Firefox, neither Safari). If FF is already opened clicking on a HyperLink gadget works as expected.

I just checked with a simple program
OpenURL("http://www.google.com")

but neither this works.
So the problem is not in MaxGUI, but resides in the OpenURL command.