HyperLinkGadget detecting change with GetGadgetColor

Just starting out? Need help? Post your questions and find answers here.
freak
PureBasic Team
PureBasic Team
Posts: 5942
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: HyperLinkGadget detecting change with GetGadgetColor

Post by freak »

Trying to put a HyperLinkGadget into an EditorGadget is an unnecessarily complex solution to a simple problem. The simple solutions are: use a WebGadget() or if you need editing capabilities, use a ScintillaGadget(). This is crossplatform and requires no hacks. The behavior can even be customized further with scintilla messages:

Code: Select all

ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)

  If *scinotify\nmhdr\code = #SCN_HOTSPOTCLICK  
    If *scinotify\position >= 20 And *scinotify\position < 35
      ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)      
    EndIf
  EndIf

EndProcedure


If OpenWindow(0, 0, 0, 400, 500, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  If InitScintilla()
    ScintillaGadget(0, 10, 10, 380, 480, @ScintillaCallBack())
    
    ; set text
    *Buffer = AllocateMemory(1000)
    PokeS(*Buffer, "In case of emergecy Visit PureBasic to get help" + Chr(10) + "Have fun", -1, #PB_Ascii)
    ScintillaSendMessage(0, #SCI_SETTEXT, 0, *Buffer)
    
    ; normal text style
    ScintillaSendMessage(0, #SCI_STYLESETFONT, 0, @"Tahoma")
    ScintillaSendMessage(0, #SCI_STYLESETSIZE, 0, 12)
    
    ; hyperlink style
    ScintillaSendMessage(0, #SCI_STYLESETFONT, 1, @"Tahoma")
    ScintillaSendMessage(0, #SCI_STYLESETSIZE, 1, 12)
    ScintillaSendMessage(0, #SCI_STYLESETFORE, 1, #Gray)
    ScintillaSendMessage(0, #SCI_STYLESETHOTSPOT, 1, #True)   
    ScintillaSendMessage(0, #SCI_SETHOTSPOTACTIVEFORE, #True, #Red)
    ScintillaSendMessage(0, #SCI_SETHOTSPOTACTIVEUNDERLINE, #True)
    
    ; apply styles
    ScintillaSendMessage(0, #SCI_STARTSTYLING, 20, $FF)
    ScintillaSendMessage(0, #SCI_SETSTYLING, 15, 1)

  EndIf
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

quidquid Latine dictum sit altum videtur
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: HyperLinkGadget detecting change with GetGadgetColor

Post by RASHAD »

The manual say nothing about HyperLink() support for any event
Now it looks that it support EventGadget() and EventType(),how come !
Thanks NM and Danilo

I do not think that WebGadget() support different color for the Hilight Color
Because it is hard coded

For ScintillaGadget yes it looks v good but still not so easy you are using a CallBack
After all I think it is the best for now
Egypt my love
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: HyperLinkGadget detecting change with GetGadgetColor

Post by Little John »

RASHAD wrote:The manual say nothing about HyperLink() support for any event
Now it looks that it support EventGadget() and EventType(),how come !
EventGadget() does of course support the HyperLinkGadget -- otherwise the HyperLinkGadget would not be usable. :-)
Help for EventGadget() wrote:After an event of type #PB_Event_Gadget (returned by WindowEvent() or WaitWindowEvent()), use this function to determine which gadget has been triggered. It returns the #Gadget number.
This applies to the HyperLinkGadget as well as to all other gadgets, no?

Unfortunately, the example in the help for HyperLinkGadget is incomplete.
freak
PureBasic Team
PureBasic Team
Posts: 5942
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: HyperLinkGadget detecting change with GetGadgetColor

Post by freak »

The ButtonGadget page also does not specifically mention EventGadget(). I think it is pretty self explanatory that a clickable gadget fires an event when clicked ;)
RASHAD wrote:I do not think that WebGadget() support different color for the Hilight Color
Because it is hard coded
Of course it does. You can modify the link behavior using CSS.
quidquid Latine dictum sit altum videtur
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: HyperLinkGadget detecting change with GetGadgetColor

Post by RASHAD »

While this is the first time I noticed what you said about ButtonGadget() :shock: I owe you one
I was using it by logic that it is created to do something
Now why do not you (Andre I mean) make a standard help for all gadgets?

For the second part if I agree with you it still not straight forward task
I prefer ScintillaGadget in this case
(Until now maybe later I will have difficulties with it :) )

Thanks freak
Egypt my love
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: HyperLinkGadget detecting change with GetGadgetColor

Post by VB6_to_PBx »

RASHAD

netmaestro

Danilo

freak

Thanks very much for all the great Code examples you've Posted !!!!

:D
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: HyperLinkGadget detecting change with GetGadgetColor

Post by IdeasVacuum »

Html code, save as, e.g, hyperlinks.html:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">
<title>Hyperlinks</title>
<style type="text/css">
body {margin: 0px; padding: 0px;}
a.hlink_1:link {color:#0000ff;}
a.hlink_1:visited {color:#ff8000;}
a.hlink_1:hover {color:#ff0000;}
a.hlink_1:active {color:#ff00ff;}
</style>
</head>

<body text="#000000" style="background-color:#ffffff; text-align:left; height:400px;">
<div style="background-color:transparent;text-align:left;margin-left:auto;margin-right:auto;position:relative;width:400px;height:400px;">

<div style="position:absolute;left:58px;top:40px;width:244px;height:20px;">
<a class="hlink_1" href="http://www.purebasic.com/"  target="_blank" style="text-decoration:underline;">http://www.purebasic.com/</a></span></div>

<div style="position:absolute;left:58px;top:80px;width:265px;height:20px;">
<a class="hlink_1" href="http://www.purebasic.fr/blog/"  target="_blank" style="text-decoration:underline;">http://www.purebasic.fr/blog/</a></span></div>
</div>
</body>
</html>
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply