Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

/CocoaControls/TextArea with Link
Function: You find this example project in your Plugins Download as a Xojo (Real Studio) project file within the examples folder: /CocoaControls/TextArea with Link
Project "TextArea with Link.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
EventHandler Sub SelChange() AddLinkButton.Enabled = me.SelLength > 0 dim n as NSTextViewMBS = me.NSTextViewMBS dim a as NSAttributedStringMBS = n.textStorage if a.Length > 0 then dim d as Dictionary = n.selectedTextAttributes dim r as NSRangeMBS = n.selectedRange if r.Location < a.Length then dim l as string = a.attributeAtIndex(a.NSLinkAttributeName, r.Location) InputField.Text = l Return end if end if InputField.Text = "" End EventHandler
End Control
Control InputField Inherits TextField
ControlInstance InputField Inherits TextField
End Control
Control AddLinkButton Inherits PushButton
ControlInstance AddLinkButton Inherits PushButton
EventHandler Sub Action() dim n as NSTextViewMBS = TextArea1.NSTextViewMBS dim a as NSMutableAttributedStringMBS = n.textStorage if InputField.Text = "" then // remove link a.removeAttribute(a.NSLinkAttributeName, n.selectedRange) else // add one a.addAttribute(a.NSLinkAttributeName, InputField.text, n.selectedRange) end if me.Enabled = false End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections




Links
MBS Xojo Plugins