Re: HyperLinkGadget detecting change with GetGadgetColor
Posted: Sat Sep 14, 2013 5:15 pm
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