Saltar para o conteúdo principal
Version: v18

Bibliotecas de objetos

Visão Geral

You can use object librairies in your forms. An object library offers a collection of preconfigured objects that can be used in your forms by simple or copy-paste or drag-and-drop.

4D proposes two kinds of object libraries:

  • a standard, preconfigured object library, available in all your projects.
  • custom object librairies, that you can use to store your favorite form objects or full project forms.

Criar e utilizar bibliotecas de objetos personalizadas

The standard object library is available from the Form editor: click on the last button of the toolbar:

The library is displayed in a separate window:

The window has the following main features:

  • Preview area with tips: The central area displays a preview of each object. You can hover on an object to obtain information about the object in a tip.
  • You can filter the window contents by using the Categories menu:
  • To use an object from the library to your form, you can either:
    • right-click on an object and select Copy in the contextual menu
    • or drag and drop the object from the library The object is then added to the form.

This library is read-only. If you want to edit default objects or create your own library of preconfigured objects or project forms, you need to create a custom object library (see below).

All objects proposed in the standard object library are described on this section on doc.4d.com.

Utilização da biblioteca de objetos padrão

You can create and use custom object libraries in 4D. A custom object library is a 4D project where you can store your favorite objects (buttons, texts, pictures, etc.) You can then reuse these objects in different forms and different projects. You can then reuse these objects in different forms and different projects.

Objects are stored with all their properties, including their object methods. Libraries are put together and used by simple drag-and-drop or copy-paste operations.

Using libraries, you can build form object backgrounds grouped by graphic families, by behavior, etc.

Creating an object library

To create an object library, select New>Object Library... from the 4D File menu or tool bar. A standard save file dialog box appears, which allows you to choose the name and the location of the object library.

Once you validate the dialog box, 4D creates a new object library on your disk and displays its window (empty by default).

You can create as many libraries as desired per project. A library created and built under macOS can be used under Windows and vice-versa.

Opening an object library

A given object library can only be opened by one database at a time. However, several different libraries can be opened in the same database.

To open a custom object library, select Open>Object Library... command in the 4D File menu or tool bar. Aparece uma caixa de diálogo padrão de ficheiro aberto, que lhe permite seleccionar a biblioteca de objectos a abrir. Pode seleccionar os seguintes tipos de ficheiros:

  • .4dproject
  • .4dz

Na realidade, as bibliotecas de objectos personalizados são projectos 4D clássicos. Apenas as seguintes partes de um projecto são expostas quando este é aberto como biblioteca:

  • formulários projecto
  • páginas formulário 1

Construir uma biblioteca de objectos

Os objectos são colocados numa biblioteca de objectos usando o método de arrastar e largar ou uma operação de cortar-copiar-colar. They can come from either a form or another object library (including the standard library). No link is kept with the original object: if the original is modified, the copied object is not affected.

In order to be able to drag and drop objects from forms to object libraries, you must make sure the Start drag and drop option in the 4D Preferences is selected.

Basic operations are available in the context menu or the options menu of the window:

  • Cortar ou Copiar para o papelão
  • Colar um objecto do papelão
  • Apagar - apaga o objecto da biblioteca
  • Renomear - aparece uma caixa de diálogo que lhe permite renomear o item. Note-se que os nomes dos objectos devem ser únicos numa biblioteca.

Pode colocar objectos individuais (incluindo subformulários) ou conjuntos de objectos numa biblioteca de objectos. Cada objecto ou conjunto é agrupado num único item:

Uma biblioteca de objectos pode conter até 32.000 elementos.

Os objectos são copiados com todas as suas propriedades, tanto gráficas como funcionais, incluindo os seus métodos. Estas propriedades são mantidas na íntegra quando o elemento é copiado para um formulário ou outra biblioteca.

Objetos dependentes

Using copy-paste or drag-and-drop with certain library objects also causes their dependent objects to be copied. For example, copying a button will cause the object method that may be attached to be copied as well. These dependent objects cannot be copied or dragged and dropped directly.

The following is a list of dependent objects that will be pasted into the library at the same time as the main object that uses them (when applicable):

  • Listas
  • Formatos/Filtros
  • Imagens
  • Dicas de ajuda (ligadas a um campo)
  • Métodos objecto