Xojo Conferences

« FileMaker DevCon in t… | Home | MBS FileMaker Plugin,… »

Tip of the day: Adding links to Textarea on OS X

A recent question was how to put a link into a textarea. You can do this with MBS Plugin like the snippets below.
The first snippet here checks to see if current cursor position has a link set:
dim n as NSTextViewMBS = textarea1.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 = ""
Second snippet shows how to remove/add a link to the current selection:
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
09 07 15 - 03:19
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.