Code: Select all
@REQUIRE "RapaGUI", {Link = True}
@APPTITLE "Hyperlink-Test"
Function p_EventFunc(msg)
Switch(msg.ID)
Case "btn1":
Local text1$ = moai.Get("link1", "url")
Local text2$ = moai.Get("link2", "url")
moai.Set("link1", "url", text2$)
moai.Set("link2", "url", text1$)
Case "btn2":
Local text1$ = moai.Get("link3", "url")
Local text2$ = moai.Get("link4", "url")
moai.Set("link3", "url", text2$)
moai.Set("link3", "label", text2$)
moai.Set("link4", "url", text1$)
moai.Set("link4", "label", text1$)
EndSwitch
EndFunction
InstallEventHandler({RapaGUI = p_EventFunc})
moai.CreateApp([[<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
<window id="mainWindow" width="300" title="Hyperlink-Test">
<hgroup>
<vgroup>
<hyperlink id="link1">https://hollywood-mal.com</hyperlink>
<hyperlink id="link2">http://amiga-news.de</hyperlink>
<button id="btn1">Switch URLs</button>
<rectangle />
</vgroup>
<vgroup>
<hyperlink id="link3" label="https://hollywood-mal.com">https://hollywood-mal.com</hyperlink>
<hyperlink id="link4" label="http://amiga-news.de">http://amiga-news.de</hyperlink>
<button id="btn2">Switch URLs and Labels</button>
<rectangle />
</vgroup>
<rectangle />
</hgroup>
</window>
</application>]])
Repeat
WaitEvent
Forever
Starting the script:
After clicking both buttons:
After resizing the window for a bit:
Result:
The links underneath have been correctly switched: clicking them opens the newly set URL.
Windows:
- a Label that comes automatically from the URL is not updated, no matter what
- after setting the Label by code, the widget is not properly resized (it is, though, after resizing the window)
- a Label that comes automatically from the URL is updated only after a resize of the window or moving the mouse over it, but not properly resized
- after setting the Label by code, the widget is not properly resized no matter what