Created
August 4, 2022 06:32
-
-
Save indiscripts/a8e526ab12f05f5ffade353676228d41 to your computer and use it in GitHub Desktop.
Basic StaticText Hyperlink Scheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const urlMouseEventHandler = function onMouse(/*MouseEvent*/ev, st,ln) | |
//---------------------------------- | |
// this :: Group | |
{ | |
st = this.children[0]; | |
ln = this.children[1]; | |
switch( ev.type ) | |
{ | |
case 'mouseover': | |
case 'mousemove': | |
st.enabled = true; | |
ln.visible = true; | |
break; | |
case 'mouseout': | |
st.enabled = false; | |
ln.visible = false; | |
break; | |
case 'mousedown': | |
if( 'target' != ev.eventPhase ) break; | |
alert("Implement your browser launcher here!"); | |
// Here use the browser launcher scheme, there are many examples on the forum! | |
// Or use: github.com/indiscripts/IdExtenso/blob/master/etc/Web/$$.Browser.jsxinc | |
default:; | |
} | |
}; | |
function TestStaticTextlink( dlg,gUrl,st,ln,t) | |
//---------------------------------- | |
{ | |
const myUrl = "https://indiscripts.com"; | |
const myColorOn = [.4,.7,.95, 1]; | |
const myColorOff = [.6,.7,.8, 1]; | |
// Dial. | |
dlg = new Window('dialog'); | |
dlg.margins = [20,100,20,20]; | |
// etc | |
// URL group component | |
gUrl = dlg.add('group'); | |
st = gUrl.add('statictext', void 0, myUrl); | |
ln = gUrl.add('group'); | |
// --- | |
gUrl.margins = 0; | |
gUrl.orientation = 'stack'; | |
st.alignment = ['center','top']; | |
ln.alignment = ['center','bottom']; | |
ln.preferredSize = {width:ln.graphics.measureString(myUrl)[0], height:1}; | |
// --- | |
st.graphics.foregroundColor = st.graphics.newPen(0,myColorOn,1); | |
st.graphics.disabledForegroundColor = st.graphics.newPen(0,myColorOff,1); | |
st.enabled = false; | |
ln.graphics.backgroundColor = ln.graphics.newBrush(0,myColorOn); | |
ln.visible = false; | |
// Events | |
t = urlMouseEventHandler; | |
gUrl.addEventListener('mouseover',t); | |
gUrl.addEventListener('mousemove',t); | |
gUrl.addEventListener('mouseout',t); | |
gUrl.addEventListener('mousedown',t); | |
dlg.show(); | |
}; | |
TestStaticTextlink(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment