« MBS @ FMTraining.TV -… | Home | New in MBS FileMaker … »

Data Detectors as context menu

Does your Xojo made application run on macOS (or iOS) and shows some text? How about adding an action button, a contextual menu or a popup-menu to offer various actions for the text?

Using the NSDataDetectorMBS class from our MBS Xojo MacCocoa Plugin, you can analyze text using Apple's frameworks. You get an array of NSTextCheckingResultMBS objects for the found details, which can include:

  • URLs
  • Email addresses
  • Phone numbers
  • Addresses
  • Transit Information
  • Dates

We can process the found information and offer action commands. This may include copying the found text. When we have an URL or can build one, we can offer to open this URL. Normally this opens a website in the default browsers. Email addresses can open a new email in the mail application. With all this actions, we can show a menu like this:

In our example we use a timer to check the text a few milliseconds of the text changing. Once checked, we could decide whether to enable the button for the actions. You may provide it as a gear button like other applications to offer these additional actions.

The example project will be included with future plugins or you can email us for a copy as usual. If you'd like to do something similar for Windows or Linux, please check our RegEx plugin and use a few regular expressions to find phone numbers, emails or URLs yourself.

22 01 24 - 09:39