Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/TextArea with Link
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/TextArea with Link
This example is the version from Wed, 7th Jul 2015.
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

The items on this page are in the following plugins: MBS MacControls Plugin.

MBS Xojo Plugins