Tech Tips — The 4 Tips of April are Here!

by Add Komoncharoensiri, Director of Technical Services at 4D Inc


As a 4D developer, you have to keep up with the new advances 4D is continuously shipping. Besides tips and tricks provided by the product team, Tech Tips are another reference for learning some of the 4D concepts.

This article covers 4 tips:

  • How to treat SQL wildcard characters as a literal string
  • Programmatically get the project name
  • Preemptive methods under the same call chain should also be preemptive
  • Creating a new View Pro document based on a Sheet

How to notarize your merged 4D application (macOS 12 & Xcode 13)

Note: Update for macOS 12/Monterey and Xcode 13. For Xcode 12 and older, see this blog post.


With Monterey (macOS 12), it’s highly recommended that you notarize applications distributed over a public network. A significant number of developers transfer their applications using a connected storage device or via file-sharing; notarization isn’t required in these cases where the user already trusts the developer. Notarization aims to assure users that the application isn’t malicious and is only required for applications downloaded from a website.

Using our built-in signature feature when building your applications with 4D v18, your application is ready to be notarized. This process is conducted outside of 4D. It involves adding an electronic signature to your application and submitting your signed application to an automated inspection service. Here’s everything you need to know:


How to define sleeping timeout for remote 4D applications

To prevent session loss, 4D monitors the sleeping state of remote 4D applications.

When a user is connected from a remote 4D application to a 4D Server and their computer goes into sleep mode, the information is sent to 4D Server. At the moment the user’s computer wakes up, the remote 4D application then recovers its execution context.


How to take advantage of GitHub actions with 4D

Your project is now on a source control system. This means that managing several versions of your software, monitoring changes, and integrating corrections or new features is much simpler now.

Why not also take advantage of continuous integration?

Starting with 4D v19, you can launch the compilation of your project with a command. As a result, you now have all the building blocks needed to automate your integration chain.

This blog post will give you an example of automation with the GitHub manager and GitHub Actions.



by Mourad Aouinat, Software Engineer at 4D Morocco

In a previous blog post, we saw how easy setting up a REST API using 4D. In this blog post, we will leverage the powerful 4D REST API in combination with React to build a To-Do app that includes features to open todos, create new ones, modify existing ones, and features for bulk modification and bulk deletion.


How to automate the compilation

Since 4D v19, you can start the compilation of a project with a simple command. You might be wondering what you can use this for!

Your team may consist of several developers, so why not automate the compilation at each code push on your source control server? It is always easier to identify an error when it is quickly detected.

Another case is when your project consists of several components. You can write a method that compiles, builds, and then copies the component to the host database.

This blog will discuss the different technical points that are very useful to create your own automation tools, along with an example application.


Toggle Dark & Light Mode on macOS in one click

As of 4D v19, you have the possibility to create applications that support the Dark and Light mode on macOS. To do this, you have to modify and check many small details: icons, widgets, texts, background colors, etc.

As a result, you need change the appearance of your mac dozens of times per hour. OK, you might be thinking, “What? All it takes is three clicks. Open the preferences panel, click the general icon, then the light or dark control, that’s it!“. But honestly, if you are a developer or a tester, repeating these actions over and over again becomes very tedious. 


CSS Media query for a dark or light UI

Dark mode has been gaining a lot of ground recently. That’s why we’ve added support for it in 4D v19, and mentioned a few ways you can adjust it to your needs in the related announcement.

In this blog post, we’ll focus on CSS and explain in detail how to set CSS styles for light and dark modes using CSS media queries.


4D View Pro: End of document loading

When you use 4D View Pro (especially in offscreen mode) with complex documents, calculating all formulas could take a while and it can be difficult to know when it’s finally finished (and it’s important to wait before you call commands such as export or print).

As a solution, we’ve introduced two new events. One of which is called for every single calculation/formula, which could be used to trigger a timer. If the time expires without another formula being finished, we can assume that the whole document is finished.

Page 4 of 11