Example: /MacControls/TextArea with Link

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

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.xojo_binary_project"
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:

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


💬 Ask a question or report a problem