« Five months until MBS… | Home | MBS Xojo Plugins, ver… »

News from the MBS Xojo Plugins Version 23.5

In this article I want to introduce you the new functionalities from the MBS Xojo Plugins in version 23.5.

DynaPDF

There is a new class for the DynaPDF area: DynaPDFIteratorMBS. The class provides an interator as an object that can be used in for-each loops in Xojo. It is an abstracted class, so we cannot create an instance by ourselves, but several methods can use the class as a return. There are currently 17 different methods that interate using it, for example over annotations, bookmarks or named destinations.

In the DynaPDFMBS class, we also have the option of creating a geospatial measure dictionary using the CreateGeospatialMeasure method. This kind of measure dictionary can be used to convert PDF units to geographic coordinates. A measure dictionary is used by the measure tool of Adobe's Acrobat and by other PDF viewers which contain a PDF compatible measure tool.

In the classes DynaPDFAnnotationExMBS and DynaPDFAnnotationMBS we have one Operator_Convert function each. This converts an object of one type of annotation into an object of the other type. DynaPDFAnnotationMBS is the older and DynaPDFAnnotationExMBS the newer class.

JSON

We rewrote JSONMBS class to use a newer C++ library. The new class should be faster, add modern features and is interface compatible. We have already reported that DynaPDF got a new class for interators. JSON also gets a new JSONIteratorMBS class, which makes it possible to work with for-each loops in Xojo. This allows you to perform interations via child nodes, child entries and child values. The appropriate methods can be found in the JSONMBS class. You can use such a for each loop, for example, in connection with the new JSONEntryMBS class, which describes an entry in a JSON object or array. Here you can see, for example, how the individual entries in a JSON interats:

Dim j As New JSONMBS

j.Value("Hello") = "World"
j.Value("Test") = "Value"
j.Value("abc") = "cde"

Dim entries() As JSONEntryMBS = j.Entries
Break

Another new feature of the plugin is the option to work with JSON Path. With the method Query you can perform a JSON Path query. For example, if you have a JSONMBS object j in which there are different objects in an array that describe different books with the keys title and price, then we can use the following code to determine the books which have a price of less than 10:

j.Query("$.book[?(@.price < 10)].title")
Another new method that also uses JSON Path is the Replace method. It searches for all values that match the JSONPath expression and replaces them with the specified value. If we stay with our example, we would use this step to find all books with the title 'A Wild Sheep Chase' and replace the price with 123.
j.Replace("$.books[?(@.title == 'A Wild Sheep Chase')].price", 123.0)

As of this release, you can now also use JMESPath for your JSON documents. JMESPath is a language with which you can modify and search your JSON objects. You can find out more about JMESPath here: https://jmespath.org/
With the new Search method, for example, you can filter the city names from several objects that describe cities in the USA for which the objects have the state with the initials WA. These names should then be output with the key WashingtonCities separated by a comma

Dim json As String = "{ ""locations"": ["+EndOfLine+_
"{""name"": ""Seattle"", ""state"": ""WA""},"+EndOfLine+_
"{""name"": ""New York"", ""state"": ""NY""},"+EndOfLine+_
"{""name"": ""Bellevue"", ""state"": ""WA""},"+EndOfLine+_
"{""name"": ""Olympia"", ""state"": ""WA""}"+EndOfLine+_
"]}"
Dim query As String = "locations[?state == 'WA'].name | sort(@) | {WashingtonCities: join(', ', @)}"

Dim j As New JSONMBS(json)
Dim r As JSONMBS = j.Search(query)

TextArea1.Text = r.toString

We also have the new Flatten method that flattens a json object or array to a single depth object of key-value pairs.The associated function Unflatten unflattens that object back to the original JSON.

XML

We have two new methods in the XML section of the XMLDocumentMBS class. At first the renameNode to well rename nodes. If simple renaming is not possible, it creates a new node with the specified name and replaces the existing node with the new node.

The other method is adoptNode. It changes the ownerDocument of a node, its children, as well as the attached attribute nodes if there are any. If the node has a parent it is first removed from its parent child list. This effectively allows moving a subtree from one document to another.

SQL

In the SQL section, we have a new property called RowsAffected for each of the two classes SQLConnectionMBS and SQLDatabaseMBS. It returns the number of rows which are affected by the last insert/update/delete command execution. This makes it easier to detect changes in a database.

New functionalities for Mac

The MBS Xojo Plugins in version 23.5 offers some more new features for Mac users

Touches in iOS

The NSTouchMBS class is a great new class. An object of this class represents the location, size, movement, and force of a touch occurring on the screen. A touch object also contains a timestamp indicating when the touch occurred, an integer representing the number of times the user tapped the screen, and the phase of the touch in the form of a constant that describes whether the touch began, moved, or ended, or whether the system canceled the touch. Matching this, we have implemented a few events that work with this class for MapKit and SceneKit on iOS. So you have events that recognize when a touch starts, ends, is canceled or a movement is executed.

NSMenu

You can use the NSMenuMBS class to display a menu in the Cocoa world. In this class we have new methods and a new event. First, we can use the new method setSelectedItems to specify the menu items in an array that should be selected and we can also read out this selection again with selectedItems.

Another new method in this class is paletteMenuWithColors. It creates a palette menu displaying user-selectable color tags using the provided template image, tinted using the specified array of color. We have a new event in the class that matches this. The PaletteSelectionChange event fires when the selection of the palette changes.

AVFoundation

Since MacOS Sonoma introduces reactions for video recording, you can configure this via AVRecorder functionalities. When running on macOS 14 or iOS 17, your application can check for effect availability and beside gesture also run effects via code via performEffectForReaction methode from the AVCaptureDeviceMBS class. According to that, there is the new AVCaptureReactionEffectStateMBS class. This reports the state of a reaction.

Remote Control

For Windows users, there are new features in the RemoteControl area, which deals with the simulating of the user's mouse and keyboard input via code. We have three new methods in the RemoteControlMBS class, each return a boolean value. WinIsNumLock, WinIsScrollLock and WinIsCapsLock. All of these methods check whether the corresponding keys are set.

We hope you will also find some interesting new features. We wish you a lot of fun with MBS Xojo Plugins version 23.5. If you have any Ideas for new cool features, need a license or have any questions, please contact us.

See also

29 11 23 - 08:44